novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 463 forks source link

can not connect on iOS 13 #544

Open sunyxiaobo opened 4 years ago

sunyxiaobo commented 4 years ago

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?

leixu2txtek commented 4 years ago

Have you try this

MQTTSSLSecurityPolicy *securityPolicy = [MQTTSSLSecurityPolicy policyWithPinningMode:MQTTSSLPinningModeNone];

securityPolicy.allowInvalidCertificates = YES;
securityPolicy.validatesCertificateChain = YES;
securityPolicy.validatesDomainName = NO;
liliangke555 commented 4 years ago

这个问题怎么解决??

liliangke555 commented 4 years ago

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);
    }];
jaylanlu commented 4 years ago

Connection reset by peer