Unable to disable ssl verification in cURL

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 18:27:10

问题


I have exposed some ReSTFul web services on a corporate network [ Company's Internal Network]. I am trying to test those using curl on windows. The address of the GET request is something like this --> (https on non standard port) https://myCompanysNet:13432/something/something/1.0.0/

curl -H "Accept:application/xml" --user username:password "https://myCompanysNet:13432/something/something/1.0.0/"

And I have added option insecure in curlrc conf. file But instead of getting the required XMLs in the response , the output is some html page showing the following error

HTTPS Request Blocked 

Your request has been blocked by because it is not allowed to use HTTP CONNECT method to port 13432. This may be due to the use of a non-standard HTTPS port.

Which is the same error page , when one tries to open restricted websites via company's network !

I have a client code written in java , which works quite fine and fetches the XMLs , but the requirement is to use curl.

EDIT 1 :- Following method is called in java client code:

static {
    disableSslVerification();
}

private static void disableSslVerification() {
    try {
        // Create a trust manager that does not validate certificate chains
        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        }
        };

        // Install the all-trusting trust manager
        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

        // Create all-trusting host name verifier
        HostnameVerifier allHostsValid = new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        };

        // Install the all-trusting host verifier
        HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (KeyManagementException e) {
        e.printStackTrace();
    }

}

来源:https://stackoverflow.com/questions/33537098/unable-to-disable-ssl-verification-in-curl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!