question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to not enforce Certificate pinning

See original GitHub issue

I am using Okhttp + Retrofit for networking in my SDK. I have a requirement to implement Certificate pinning but not enforce it. We just need to get the failure reports for pinning failure and would like the connection to go through for now during the monitoring period. TrustKit is another Certificate pinning library which provides this option to set enforce = false. With this, the connection itself wouldn’t fail but we can get the failure reports.

I do not see a way to achieve similar behavior using the Okhttp CertificatePinner. Are there any plans to add this functionality? Or do you have any suggestions on how I can achieve this behavior using the existing functionality?

Would have been easier if we could extend CertificatePinner class and override check() ?

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
shenoymukeshcommented, Apr 7, 2020

@yschimke Does below code make sense?

`

class CustomCertCheckInterceptor(val certificatePinner: CertificatePinner) : Interceptor {

override fun intercept(chain: Interceptor.Chain): Response {
    val host = chain.request().url.host
    val certs = chain.connection()?.handshake()?.peerCertificates ?: emptyList()

    try {
        certificatePinner.check(host, certs)
    } catch (e: SSLPeerUnverifiedException) {
        //Do the logging and reporting for pinning failure
    }
    return chain.proceed(chain.request())
}

}

`

0reactions
yschimkecommented, Apr 10, 2020

@shenoymukesh The point of putting the question on stackoverflow is to use that for discussion, and not continuing the noise to other developers here. Closing this discussion. Please reply there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop Certificate Pinning | DigiCert.com
Certificate pinning restricts which certificates are considered valid for a particular website, limiting risk. Instead of allowing any trusted ...
Read more >
Certificate and Public Key Pinning | OWASP Foundation
The first thing to decide is what should be pinned. For this choice, you have two options: you can (1) pin the certificate;...
Read more >
OkHttp for Android: Option to NOT enforce Certificate
I have a requirement to implement Certificate pinning but not enforce it. We just need to get the failure reports for pinning failure...
Read more >
Enterprise Certificate Pinning | Microsoft Learn
Enterprise certificate pinning is a Windows feature for remembering, or pinning a root issuing certificate authority or end entity ...
Read more >
Identity Pinning: How to configure server certificates for your app
Pinning cannot loosen the trust requirements of your app — it can only tighten them. You still always need to meet the system's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found