Code Monkey home page Code Monkey logo

Comments (4)

bobcarroll avatar bobcarroll commented on July 20, 2024 2

Sorry, but disabling certificate validation is a spectacularly bad idea. You might as well not even use SSL because it will offer you nothing but processing overhead. If you really need this behaviour then I would suggest subclassing the JiraClient class and overriding the constructor with your own implementation.

from jira-client.

fkrauthan avatar fkrauthan commented on July 20, 2024 1

In case someone else runs into that issue and needs a fix for this you can use the following code to patch the httpclient to allow self signed certificates:

        // Create a trust rest client
        HttpClient httpClient;
        try {
            SSLContext sslContext = SSLContext.getInstance("SSL");

            // set up a TrustManager that trusts everything
            sslContext.init(null, new TrustManager[]{new X509TrustManager() {
                public X509Certificate[] getAcceptedIssuers() {
                    return null;
                }

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

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

            SSLSocketFactory sf = new SSLSocketFactory(sslContext);
            Scheme httpsScheme = new Scheme("https", 443, sf);
            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(httpsScheme);

            ClientConnectionManager cm = new BasicClientConnectionManager(schemeRegistry);
            httpClient = new DefaultHttpClient(cm);
        } catch (Exception ignored) {
            return;
        }

        // Patch RestClient
        try {
            RestClient restClient = client.getRestClient();
            Field httpClientField = restClient.getClass().getDeclaredField("httpClient");
            httpClientField.setAccessible(true);
            httpClientField.set(restClient, httpClient);
        } catch (Exception ignored) {
        }

client is the initialized instance of JiraClient

from jira-client.

fkrauthan avatar fkrauthan commented on July 20, 2024

Like I've said I don't think it is a bad idea if you are in a corporate environment. But ok if you don't wanna support a simple feature like that

from jira-client.

przemekk13 avatar przemekk13 commented on July 20, 2024

Thanks for the patch. I agree, corporate enviroments need this feature.

from jira-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.