Error: Name not maching for self signed SSL certificates on Android

心不动则不痛 提交于 2019-12-01 11:30:45
Bruno

I have verified and the server address is exactly maching the Common Name of my certificate (it is actually just an IP address).

Android's host name verifier is more strictly compliant with RFC 2818 than some browsers. According to the specification, if an IP address is used, it must be in a Subject Alternative Name entry of IP address type: not on a SAN entry of DNS type or in the CN:

If a subjectAltName extension of type dNSName is present, that MUST be used as the identity. Otherwise, the (most specific) Common Name field in the Subject field of the certificate MUST be used. Although the use of the Common Name is existing practice, it is deprecated and Certification Authorities are encouraged to use the dNSName instead.

[...]

In some cases, the URI is specified as an IP address rather than a hostname. In this case, the iPAddress subjectAltName must be present in the certificate and must exactly match the IP in the URI.

The easiest would be to use a host name. (Using IP addresses in certificates is never really practical.) Alternatively, generate a certificate with a SAN IP address entry. (You may be interested in this.)

First, the credential storage on Android 2.x is only for the VPN and WiFi applications, the browser doesn't see it. You can't install your own certificate in the trusted certificate store (unless you have a rooted device).

Is you our webapp on a public IP address or a local one you are accessing over WiFi? You might want to look at the logcat output, there might be some warnings that will give you a hint there. Also try from another device and/or the emulator (different Android version if possible) and compare messages/behaviour.

jww

so I am still working to find a final solution to my issue - not having any warning popping up on the Android browse

Nikolay Elenkov told you why you can't save a certificate to the trusted store on Android. That has changed recently, but does not help with older Android clients. For a brief history of Android's Keychain and Keystore, see Are there any system certificates storages on Android? (it refers to two posts by Nikolay).

Because you are working in the Android browser, you need to use a a CA which is already present in the Android store. To get a server certificate from a CA already trusted, try StartCom. StartCom offers free Class 1 certificates and their root is trusted in most mobile and desktop browsers. (Keep in mind they charge for revocation, if needed).

For completeness, if you wrote the client yourself, then you would provide a custom X509TrustManager and override checkServerTrusted to accept your certificate. It would not require any interaction with a Keystore, Keychain, or external CAs. But you don't have that option because you did not write the browser.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!