Здравствуйте, я использую приведенный ниже код для вызова API, но я получаю путь сертификата не найден, но когда я нажимаю API в Google Chrome, он работает.
, пожалуйста, помогите мне кто-нибудь.
// Create a KeyStore containing our trusted CAs
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", MultiAuthConstants.CRT);
// Create a TrustManager that trusts the CAs in our KeyStore
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
tmf.init(keyStore);
// Create an SSLContext that uses our TrustManager
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, tmf.getTrustManagers(), null);
httpURLConnection = (HttpsURLConnection) new URL(url).openConnection();
httpURLConnection.setSSLSocketFactory(context.getSocketFactory());
//device certificate i am reading using below code.
KeyChain.choosePrivateKeyAlias(this, new KeyChainAliasCallback() {
public void alias(String alias) {
X509Certificate[] certificates = getCertificateChain(alias);
MultiAuthConstants.CRT = certificates[0];
}
},
null, // List of acceptable key types. null for any
null, // issuer, null for any
null, // host name of server requesting the cert, null if unavailable
-1, // port of server requesting the cert, -1 if unavailable
"");