因此,在我的清单中,我指定目标转换23一切正常,但是当我指定targetsdkversion 23时,我无法进行api调用。我不断收到以下错误。
10-28 09:09:40.462: I/System.out(13743): <html><head><title>Request Rejected</title></head><body>The requested URL was rejected. Please consult with your administrator.<br><br>Your support ID is: 12896453146718027503</body></html>
那么为什么它在22上工作,但在23岁时我得到了这个错误。这是我的实施。
public static SSLContext getSSL() {
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
AssetManager assetManager = BankNizwaApp.getAppContext()
.getAssets();
InputStream caInput = assetManager.open("cert.pem");
java.security.cert.X509Certificate ca = null;
try {
ca = (java.security.cert.X509Certificate) cf
.generateCertificate(caInput);
/*
* System.out.println("BankNizwa: " +
* ((java.security.cert.X509Certificate) ca) .getSubjectDN());
*/
} catch (Exception er) {
//System.out.println("BankNizwa: " + er.getMessage());
} finally {
caInput.close();
}
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
keyStore.load(null, null);
keyStore.setCertificateEntry("ca",
(java.security.cert.X509Certificate) ca);
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(tmfAlgorithm);
tmf.init(keyStore);
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, tmf.getTrustManagers(), null);
return context;
} catch (Exception e1) {
// System.out.println("BankNizwaaaaa: "+e1.getMessage());
return null;
}
}
HttpURLConnection conn = (HttpURLConnection) url2
.openConnection();
conn.setReadTimeout(180000);
((HttpsURLConnection) conn).setSSLSocketFactory(Common
.getSSL().getSocketFactory());
conn.setConnectTimeout(180000);
conn.setRequestMethod("GET");
conn.setDoInput(true);
// conn.setDoOutput(true);
conn.setRequestProperty("Cache-Control", "no-cache");
String sessionId = "JSESSIONID=" + Common.getAuthCode();
conn.setRequestProperty("Cookie", sessionId);
conn.setRequestProperty("User-Agent",
System.getProperty("http.agent"));