I am using SSL cert pinning in retrofit with using sha256 key. But, it gets expire after certain times. At that time I have to update applications with new sha256 key. This is not reliable practice for customers to update app every time. How can I prevent this?
val certificatePinner: CertificatePinner = CertificatePinner.Builder()
.add(
certificateBase,
certificateSHA
).build()
builder.certificatePinner(certificatePinner)
second query, If I dont want to use this certPinning in retrofit, I would choose to implement public pinning using .pem certificates file. Ref link: https://owasp.org/www-community/controls/Certificate_and_Public_Key_Pinning Is public pinning require to update app everytime? Is there any pinning method which doesn’t require to update applications, just one time pinning. Thanks in Advance.
Some amount of pin rotation is unavoidable, as SSL certificates expire or need to be replaced due to security breaches. You can control the expiration frequency by purchasing a longer-lived certificate. Or, pin to the SSL certificate authority's certificate up the chain, rather than your own, though this offers somewhat less security.
We do not know what you mean by "everytime". If the SSL certificate that you are pinning against changes, you need to update the app to reflect the new pins.
We do not know what you mean by "every time". If the SSL certificate that you are pinning against changes, you need to update the app to reflect the new pins. This is the point of certificate pinning, because your app has no way to distinguish an SSL certificate that was replaced intentionally and an SSL certificate that was replaced by a MITM attacker.