socket.io-client-swift icon indicating copy to clipboard operation
socket.io-client-swift copied to clipboard

Socket.IO pinning certificate not working in v16.x

Open lamb-mei opened this issue 4 years ago • 2 comments

I try pinning certificate but not work

The document does not contain CertificatePinning description in version 16.x

SocketIO Version

pod 'Socket.IO-Client-Swift', '16.0.1'

Init SocketIO


let certificatePinning = SocketIOCertificatePinning(validateHost:true)

let config: SocketIOClientConfiguration = [.log(false),
                                                       .forceNew(false) ,
                                                       .connectParams(["token": connect_token]),
                                                       .compress,
                                                       .reconnects(false),
                                                       .security(certificatePinning) /*憑證綁定*/
            ]
SocketManager(socketURL: url, config: config)

Class SocketIOCertificatePinning

public class SocketIOCertificatePinning: CertificatePinning {

    var validateHost: Bool = false
    public init(validateHost: Bool) {
        self.validateHost = validateHost
    }

    public func evaluateTrust(trust: SecTrust, domain: String?, completion: ((PinningState) -> ())){

        let e = CFErrorCreate(kCFAllocatorDefault, "FoundationSecurityError" as NSString?, 100, nil)
        completion(.failed(e))
    }
}

i try call completion(.failed(e))

But allways allow Certificate

What did I do wrong?

lamb-mei avatar Aug 18 '21 08:08 lamb-mei

+1 I am also trying to figure out how to implement Cert pinning, but there are little to no resource on this.

prgorasiya avatar Dec 28 '21 04:12 prgorasiya

@prgorasiya @lamb-mei Yes.. same for me.. Any workaround for this..

Rijalab avatar Oct 20 '22 08:10 Rijalab