ckrey / MQTTChat

Demonstration iOS App for MQTT-Client-Framework
Eclipse Public License 1.0
96 stars 30 forks source link

Using TLS / SSL is error #7

Closed ayzen1988 closed 6 years ago

ayzen1988 commented 6 years ago

iOS use the following code

MQTTSession session = [[MQTTSession alloc] init]; NSString cerPath = [[NSBundle bundleForClass:[MQTTSession class]] pathForResource:@"client" ofType:@"cer"];//证书的路径 NSData *certData = [NSData dataWithContentsOfFile:cerPath];

MQTTSSLSecurityPolicy *securityPolicy = [MQTTSSLSecurityPolicy policyWithPinningMode:MQTTSSLPinningModeCertificate];

securityPolicy.allowInvalidCertificates = YES; securityPolicy.pinnedCertificates = @[certData]; session.securityPolicy = securityPolicy; [session connectToHost:kMQTTTestServerHost port:1883 usingSSL:YES];


Server get error code 1507900609: New connection from 192.168.0.37 on port 1883. 1507900609: OpenSSL Error: error:140890C7:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:peer did not return a certificate 1507900609: Socket error on client , disconnecting.

How can i solve it?help me.

ckrey commented 6 years ago

As MQTTChat is only a demonstration iOS App for MQTT-Client-Framework

For all documentation, issues, etc. please refer to the MQTT-Client-Framework

You can see how to use client certificates in the documentation and there are a number of issues discussing this topic