Dza*_*ata 1 apache ssl https android
我正在为Android写简单的记事本,通过互联网与我的服务器同步数据.我使用了来自startssl的https和免费证书,一切顺利.后来我用它自己的ssl证书添加了新的虚拟主机,我的应用程序突然停止了对服务器的连接.它抛出:
javax.net.ssl.SSLException: hostname in certificate didn't match: <www.rapidnote.emendus.ovh> != <othersite.emendus.ovh> OR <othersite.emendus.ovh> OR <emendus.ovh>
Run Code Online (Sandbox Code Playgroud)
它尝试从不同的apache虚拟主机验证完全不同的证书.我的用于rapidnote虚拟主机的apache配置是:
<VirtualHost *:80>
ServerName rapidnote.emendus.ovh
ServerAlias www.rapidnote.emendus.ovh
Redirect Permanent / https://www.rapidnote.emendus.ovh
</VirtualHost>
<VirtualHost *:443>
ServerName rapidnote.emendus.ovh
DocumentRoot /var/www/rapidnote
SSLEngine on
SSLCertificateFile cert_location/rapidnote.emendus.ovh.crt
SSLCertificateKeyFile key_location/rapidnote.emendus.ovh.key
SSLCertificateChainFile cert_location/sub.class1.server.ca.pem
</VirtualHost>
<VirtualHost *:443>
ServerName www.rapidnote.emendus.ovh
DocumentRoot /var/www/rapidnote
SSLEngine on
SSLCertificateFile cert_location/www.rapidnote.emendus.ovh.crt
SSLCertificateKeyFile key_location/www.rapidnote.emendus.ovh.key
SSLCertificateChainFile cert_location/sub.class1.server.ca.pem
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("https://www.rapidnote.emendus.ovh/" + paramScriptName);
HttpResponse response = httpClient.execute(httpPost);
Run Code Online (Sandbox Code Playgroud)
如果我othersite.emendus.ovh在apache中关闭虚拟主机,则SSLException消息说:
<www.rapidnote.emendus.ovh> != <rapidnote.emendus.ovh> OR <rapidnote.emendus.ovh> OR <emendus.ovh>
Run Code Online (Sandbox Code Playgroud)
如果然后我改"https://www.rapidnote.emendus.ovh/"到"https://rapidnote.emendus.ovh/",它开始工作.我检查了两个(www.和非www)证书,两者中的通用名称都是正确的.我认为它应该验证我在HttpPost构造函数中给他的域证书,而不是我的服务器中的其他随机证书...
我使用了一些测试网站来验证我的ssl配置,它表示一切都很好.
一切都在发生android 4.2.2 (API 17).我用min SDK 14和构建应用程序target SDK API 20 Android 4.4 (KitKat Wear)
如何告诉他验证为此域名指定的正确证书?是应用程序或Apache的网站上的问题?
| 归档时间: |
|
| 查看次数: |
4129 次 |
| 最近记录: |