вызовите trustAllHttpsCertificates () перед
HostnameVerifier hv = new HostnameVerifier (), и он будет работать
пакет com.americanexpress.mobl.centurion.app.util;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
открытый класс miTM реализует javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
public void checkClientTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
// TODO Auto-generated method stub
return;
}
public void checkServerTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
// TODO Auto-generated method stub
return;
}
public X509Certificate[] getAcceptedIssuers() {
// TODO Auto-generated method stub
return null;
}
public boolean isClientTrusted(java.security.cert.X509Certificate[] certs)
{
return true;
}
public boolean isServerTrusted(java.security.cert.X509Certificate[] certs)
{
return true;
}
public static void trustAllHttpsCertificates () создает исключение {
javax.net.ssl.TrustManager [] trustAllCerts = new javax.net.ssl.TrustManager [1];
javax.net.ssl.TrustManager tm = new miTM ();
trustAllCerts [0] = tm;
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance ("SSL");
sc.init (null, trustAllCerts, null);
javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory (sc.getSocketFactory ());
} * +1010 *
}