Open sunyxiaobo opened 4 years ago
Have you try this
MQTTSSLSecurityPolicy *securityPolicy = [MQTTSSLSecurityPolicy policyWithPinningMode:MQTTSSLPinningModeNone];
securityPolicy.allowInvalidCertificates = YES;
securityPolicy.validatesCertificateChain = YES;
securityPolicy.validatesDomainName = NO;
这个问题怎么解决??
self.session = [[MQTTSessionManager alloc] init]; self.session.delegate = self;
[self.session connectTo:self.mqttSettings[@"host"]
port:[self.mqttSettings[@"port"] intValue]
tls:[self.mqttSettings[@"tls"] boolValue]
keepalive:60
clean:YES
auth:YES
user:self.mqttSettings[@"userId"]
pass:self.mqttSettings[@"password"]
will:NO
willTopic:@""
willMsg:nil
willQos:MQTTQosLevelAtMostOnce
willRetainFlag:NO
withClientId:clienId
securityPolicy:[self customPlicy]
certificates:nil
protocolLevel:MQTTProtocolVersion311
connectHandler:^(NSError *error) {
NSLog(@"连接错误----%@",error);
}];
(MQTTSSLSecurityPolicy *)customPlicy {
MQTTSSLSecurityPolicy *securityPolicy = [MQTTSSLSecurityPolicy policyWithPinningMode:MQTTSSLPinningModeNone]; securityPolicy.allowInvalidCertificates = YES; securityPolicy.validatesCertificateChain = YES; securityPolicy.validatesDomainName = NO;
return securityPolicy;
}
就这样一直连接不上
Connection reset by peer
It can connect to Server with SSL on iOS 13. The error message is "mqttTransport didFailWithError Error Domain=MQTT Code=-9807 "Unable to apply security policy, the SSL connection is insecure!"". And it can connect to server on device that the system is below iOS 13. Is there anyone encounter this issue?