Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support -cert and -noCertificateCheck in WebSocket mode #690

Merged
merged 1 commit into from Oct 24, 2023

Conversation

basil
Copy link
Member

@basil basil commented Oct 23, 2023

I couldn't see a good reason to support these in one transport but not the other, given that it is just a matter of plumbing through the relevant SSLContext to the HTTP layer.

Testing done

Set up a WebSocket agent against my controller with a self-signed HTTPS certificate. Verified the connection failed before this PR and passed after this PR when adding -noCertificateCheck. I also tested that I could connect with HTTPS and -noCertificateCheck without WebSocket. I did not test -cert because I don't actually have a valid certificate for my local testing environment. But this code is common code, so if it's plumbed through correctly in one case it should be plumbed through correctly in the other as well.

@basil basil added the enhancement For changelog: An enhancement providing new capability. label Oct 23, 2023
Comment on lines +1063 to +1066
SSLContext sslContext = null;
if (noCertificateCheck) {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{new NoCheckTrustManager()}, new SecureRandom());
} else if (x509Certificates != null && !x509Certificates.isEmpty()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from JnlpAgentEndpointResolver#openURLConnection to facilitate code reuse.

Comment on lines -300 to -301
"-cert",
"-noCertificateCheck",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these restrictions.

@basil basil merged commit 507a8ba into jenkinsci:master Oct 24, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For changelog: An enhancement providing new capability.
Projects
None yet
2 participants