I have passed a wrong hash in Certificate Pinner ,...
# ktor
a
I have passed a wrong hash in Certificate Pinner , but I am still getting 200 status code using this client implementation . What could be the reason here ? I believe this call should fail with exception
Copy code
val cp = CertificatePinner.Builder().add("ktor.io", "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=").build()
usePreconfiguredSession(
    session =  NSURLSession.sessionWithConfiguration(
        NSURLSessionConfiguration.defaultSessionConfiguration,
        NsUrlSessionDelegate(),
        delegateQueue = NSOperationQueue()
    ),
    delegate = KtorNSURLSessionDelegate(cp),
)
When I am doing this way then certificate Pinning is respected
Copy code
configureSession {
     NSURLSession.sessionWithConfiguration(
        NSURLSessionConfiguration.defaultSessionConfiguration,
        NsUrlSessionDelegate(),
        delegateQueue = NSOperationQueue()
    )
}

handleChallenge(cp)
But my custom NsUrlSessionDelegate callbacks are not executing in this case
What is the difference in both cases
a
The difference is that in the first code snippet, the delegate is only used to call the read method. As far as I understand, to make the challenge handler be called in the right place, the session must be created with the
KtorNSURLSessionDelegate
delegate.