简体   繁体   English

Android和iOS中的证书固定

[英]Certificate pinning in Android & iOS

When we import SSL Certificate in our app, for certificate pinning we have to update apk/ipa every-year at the time of Certificate update. 当我们在我们的应用程序中导入SSL证书时,对于证书固定,我们必须在证书更新时每年更新apk / ipa。

Can we overcome this ! 我们可以克服这个!

References : https://infinum.co/the-capsized-eight/articles/securing-mobile-banking-on-android-with-ssl-certificate-pinning 参考文献: https//infinum.co/the-capsized-eight/articles/securing-mobile-banking-on-android-with-ssl-certificate-pinning

DRAWBACKS Less flexibility - when you do SSL certificate pinning, changing the SSL certificate is not that easy. 缺点灵活性 - 当您执行SSL证书固定时,更改SSL证书并非易事。 For every SSL certificate change, you have to make an update to the app, push it to Google Play and hope the users will install it. 对于每个SSL证书更改,您必须对应用程序进行更新,将其推送到Google Play并希望用户安装它。

Please guide to overcome this. 请指导克服这一点。

Have a look at this article about certificate pinning and public key pinning: https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning 看看这篇关于证书固定和公钥固定的文章: https//www.owasp.org/index.php/Certificate_and_Public_Key_Pinning

An important question is what you want to pin. 一个重要的问题是你想要什么。 If you don't want to release a new version every time the certificate changes you can also key to the public key of the certificate, since you can keep the same public key when you renew your certificate your app will still work with a new certificate. 如果您不希望每次证书更改时都发布新版本,您也可以键入证书的公钥,因为您可以在续订证书时保留相同的公钥,您的应用程序仍然可以使用新证书。

Another option is not to pin to your server certificate but to the intermediate or the root certificate of the CA. 另一种选择不是固定到您的服务器证书,而是固定到CA的中间证书或根证书。 The intermediate certificate is usually valid for a longer time. 中间证书通常有效期较长。

There is no way to overcome this, but you can make this less painful: 没有办法克服这一点,但你可以减少痛苦:

  • If you pin the anchor certificate (the CA), that certificate is not going to change often (every 5 or 10 years). 如果您固定锚证书(CA),则该证书不会经常更改(每5年或10年)。
  • Better than pinning the certificate itself, you should pin the key inside the certificate which doesn't change when you re-issue a certificate. 比固定证书本身更好,您应该将密钥固定在证书中,当您重新颁发证书时,密钥不会改变。
  • Most pinning libraries (such as the one I worked on: https://github.com/datatheorem/TrustKit ) let you specify an expiration date for the pinning policy, so that in case you forget to update the IPA/APK, the App still works for your users (but with pinning disabled, which is still relatively secure). 大多数固定库(例如我使用的工具: https//github.com/datatheorem/TrustKit )允许您指定固定策略的截止日期,以便在您忘记更新IPA / APK时,应用程序仍适用于您的用户(但禁用固定钉,仍然相对安全)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM