admin管理员组文章数量:1125978
My goal is to implement a wss connection using SSL pinning on an React Native iOS module. For this problem, I chose to use Jetfire. I have the following class:
@interface RCTWebSocketSslPinning : RCTEventEmitter <RCTBridgeModule, JFRWebSocketDelegate>
@property (nonatomic, strong) JFRWebSocket *socket;
@property bool hasListeners;
-(void)sendEventToJavaScript:(NSString *)eventName withParams:(id)params;
@end
And the following fetch
method:
RCT_EXPORT_METHOD(fetch:(NSString *)url withOptions:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback)
{
RCTLogInfo(@"Pretending to fetch %@ with options: %@", url, options.description);
self.socket = [[JFRWebSocket alloc] initWithURL:[NSURL URLWithString: url] protocols:nil];
self.socket.delegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@"rootCA_public" ofType:@"cer"];
NSData *data = [NSData dataWithContentsOfFile:path];
if (data) {
NSLog(@"Certificate loaded successfully!");
} else {
NSLog(@"Failed to load certificate. Check the file path.");
callback(@[ @"Failed to load certificate.", [NSNull null]]);
}
self.socket.security = [[JFRSecurity alloc] initWithCerts:@[[[JFRSSLCert alloc] initWithData:data]] publicKeys:YES];
[self.socket connect];
callback(@[[NSNull null], @"WebSocket fetch complete."]);
}
I implemented this method following the Jetfire guide here however when I run the program I get a run-time error within JFRSecurity.m:
- (SecKeyRef)extractPublicKeyFromCert:(SecCertificateRef)cert policy:(SecPolicyRef)policy {
SecTrustRef trust;
SecTrustCreateWithCertificates(cert,policy,&trust); // ERROR: Thread x: EXC_BAD_ACCESS (code=1, address=0x8)
SecTrustResultType result = kSecTrustResultInvalid;
SecTrustEvaluate(trust,&result);
SecKeyRef key = SecTrustCopyPublicKey(trust);
CFRelease(trust);
return key;
}
I analyzed the project and I get this message:
I'm not familiar with Objective-C, and I'm not sure if this is a problem with the library that I'm using or if it's the way I'm attempting to extract the certificate from path.
本文标签:
版权声明:本文标题:sslpinning - How do I implement SSL Pinning using acmacalisterjetfire? (Objective-C) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736602800a1945257.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论