diff --git a/SocketRocket/SRWebSocket.m b/SocketRocket/SRWebSocket.m index efe6488e1..9d9539805 100644 --- a/SocketRocket/SRWebSocket.m +++ b/SocketRocket/SRWebSocket.m @@ -186,14 +186,16 @@ - (instancetype)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols allowsUntrustedSSLCertificates:(BOOL)allowsUntrustedSSLCertificates { SRSecurityPolicy *securityPolicy; - BOOL certificateChainValidationEnabled = !allowsUntrustedSSLCertificates; - + NSArray *pinnedCertificates = request.SR_SSLPinnedCertificates; + if (pinnedCertificates) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated" - - securityPolicy = [[SRSecurityPolicy alloc] initWithCertificateChainValidationEnabled:certificateChainValidationEnabled]; - + securityPolicy = [SRSecurityPolicy pinnningPolicyWithCertificates:pinnedCertificates]; #pragma clang diagnostic pop + } else { + BOOL certificateChainValidationEnabled = !allowsUntrustedSSLCertificates; + securityPolicy = [[SRSecurityPolicy alloc] initWithCertificateChainValidationEnabled:certificateChainValidationEnabled]; + } return [self initWithURLRequest:request protocols:protocols securityPolicy:securityPolicy]; }