我正在使用 SocketRocket,到目前为止一切正常,今天我想尝试确定一个(自签名)证书,但出现错误:
- (void)connectWebSocket {
webSocket.delegate = nil;
webSocket = nil;
NSString *urlString = [NSString stringWithFormat: @"wss://%@:%@", server_ip, server_port];
//NSLog(@"%@", urlString);
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]
cachePolicy: NSURLRequestUseProtocolCachePolicy
timeoutInterval:5.0];
// pin down certificate
NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"myOwnCertificate" 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]];
SRWebSocket *newWebSocket = [[SRWebSocket alloc] initWithURLRequest: request];
newWebSocket.delegate = self;
[newWebSocket open];
socketIsOpen = true;
}
错误:“NSURLRequest”没有可见的@interface 声明选择器“setSR_SSLPinnedCertificates:”
我错过了什么吗?
谢谢!