0

So when in my manifest I speciay targetsdkversion 23 everything works normal, but when I specify targetsdkversion 23 I am unable to make api calls.I keep getting the following error.

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>

So why does it work on 22, but on 23 i get that error. Here is my implementation.

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"));
user3278732
  • 1,694
  • 10
  • 31
  • 67
  • So when in my manifest I speciay targetsdkversion 22 everything works normal, but when I specify targetsdkversion 23.. – user3278732 Oct 28 '15 at 07:15
  • The permission that are set in to your manifest is slightly differ in marshmallow . refer this .>http://stackoverflow.com/questions/32159232/android-6-marshmallow-requests-for-some-specific-permissions-are-instantly-deni – Radhey Oct 28 '15 at 07:29
  • this are permissions i have READ_PHONE_STATE-1 READ_CONTACTS-1 PHONE_STATE-1 CALL_PHONE-1WRITE_EXTERNAL_STORAGE-1 READ_EXTERNAL_STORAGE-1 ACCESS_MOCK_LOCATION-1 ACCESS_FINE_LOCATION-1 ACCESS_COARSE_LOCATION-1*/ which one is related? – user3278732 Oct 28 '15 at 07:56
  • If you have control over the server-side app, pls debug it to check. IMO, the client app sent message succesfully – BNK Oct 28 '15 at 08:09
  • If i request READ_PHONE_STATE or CALL_PHONE , and then i force close my app..then reopen my app.it works. strange. but it does not work if i request and make api call.i have to force quit and reopen app – user3278732 Oct 28 '15 at 08:25

0 Answers0