Wednesday, 8 March 2017


When you see this error:

That means the server request cert checking. So if your don't have the cert "accepted" by your server, your rest client need to ignore that.

if you are using node restler, then you need to :

        rejectUnauthorized: false,

if you are using android okhttp, then you need to use a unsafeclient:

    private static OkHttpClient getUnsafeOkHttpClient() {
        try {
            // Create a trust manager that does not validate certificate chains            final TrustManager[] trustAllCerts = new TrustManager[] {
                    new X509TrustManager() {
                        @Override                        public void checkClientTrusted([] chain, String authType) throws CertificateException {

                        @Override                        public void checkServerTrusted([] chain, String authType) throws CertificateException {

                        @Override                        public[] getAcceptedIssuers() {
                            return new[]{};

            // Install the all-trusting trust manager            final SSLContext sslContext = SSLContext.getInstance("SSL");
            sslContext.init(null, trustAllCerts, new;
            // Create an ssl socket factory with our all-trusting manager            final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();

            OkHttpClient.Builder builder = new OkHttpClient.Builder();
            builder.hostnameVerifier(new HostnameVerifier() {
                @Override                public boolean verify(String hostname, SSLSession session) {
                    return true;

        } catch (Exception e) {
            throw new RuntimeException(e);

No comments:

Post a comment