在项目中,如果你使用的是SRWebSocket,需要采用wss的话,请看一下代码
NSURL *url = [[NSURL alloc] initWithString: [NSString stringWithFormat:@"wss://%@:%@",Socket_Host, Socket_Post]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"catchtoy.itcheku.com" ofType:@"cer"];
NSData *certData = [[NSData alloc] initWithContentsOfFile:cerPath];
CFDataRef certDataRef = (__bridge CFDataRef)certData;
SecCertificateRef certRef = SecCertificateCreateWithData(NULL, certDataRef);
id certificate = (__bridge id)certRef;
[request setSR_SSLPinnedCertificates:@[certificate]];
self.webSocket = [[SRWebSocket alloc] initWithURLRequest:request];
如果是ws的接入
self.webSocket = [[SRWebSocket alloc]initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"ws://%@:%@",Socket_Host, Socket_Post]]];
ps:希望能帮到你..