我正在使用WMS图层修补android。我想加载图层的服务之一是通过Https提供服务。我找到的wms图层示例使用:
InputStream input = null;
try {
input = url.openStream();
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
其中url是类型URL,并设置为使用HTTPS的网址。这会引发错误,因为我怀疑我必须设置我的证书或其他东西。无论如何只是说接受蛮力这接受证书?我在c#中尝试了类似的东西,并且基本上能够调用它:
使https工作的C#代码:
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AcceptAllCertifications);
...
...
public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification,
System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
//this might be useful later too
//http://blog.jameshiggs.com/2008/05/01/c-how-to-accept-an-invalid-ssl-certificate-programmatically/
return true;
}