Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Domain=MQTT Code=-9807 "Unable to apply security policy, the SSL connection is insecure!" #592

Open
ml1732457 opened this issue May 27, 2021 · 0 comments

Comments

@ml1732457
Copy link

//证书1
NSString *ca = [[NSBundle mainBundle] pathForResource:@"AmazonRootCA1" ofType:@"pem"];
NSString *ca1 = [[NSBundle mainBundle] pathForResource:@"certificate" ofType:@"der"];
NSString *ca2 = [[NSBundle mainBundle] pathForResource:@"client" ofType:@"key"];

//证书2
NSString *client = [[NSBundle mainBundle] pathForResource:@"certificate" ofType:@"p12"];//注意不可以用client命名,否则无法获取到文件路径

NSArray *myCerts = [MQTTCFSocketTransport clientCertsFromP12:client passphrase:@"123"];

if (myCerts) {
    NSLog(@"myCerts ok");
}else{
    NSLog(@"myCerts error");
}

_sslTransport.certificates = [MQTTSSLSecurityPolicyTransport clientCertsFromP12:client passphrase:@"123"];

_securityPolicy = [MQTTSSLSecurityPolicy policyWithPinningMode:MQTTSSLPinningModeCertificate];

_securityPolicy.allowInvalidCertificates = YES;
_securityPolicy.validatesDomainName = NO;
_securityPolicy.validatesCertificateChain = NO;

NSLog(@"----------%@",@[[NSData dataWithContentsOfFile:ca],[NSData dataWithContentsOfFile:ca1],[NSData dataWithContentsOfFile:ca2]]);

_securityPolicy.pinnedCertificates = @[[NSData dataWithContentsOfFile:ca],[NSData dataWithContentsOfFile:ca1],[NSData dataWithContentsOfFile:ca2]];

Short description

The certificate is set but keeps reporting errors,
but I used Mac tools to debug MQTT just fine!

Environment

  • Operating system: iOS, tvOS, macOS
  • Software version:
  • Package Manager: Cocoapods, Carthage, Manual
  • MQTTClient version:
  • MQTT Broker used: mosquitto, HiveMQ, vernemq, ...

Link to logs

Create a GIST which is a paste of your logs, and link them here.
Please do NOT paste your full logs here, it will make issue very long and hard to read!

Steps to reproduce

Expected behaviour

Actual behaviour

Other information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant