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

Allow disabling HTTPs cert validation of JNLP endpoint when starting Remoting from Main #210

Merged
merged 6 commits into from
Nov 20, 2017

Conversation

oleg-nenashev
Copy link
Member

It is an attempt to improve #205 and to reuse existing code from @stephenc . Originally the HTTPs certificate validation has been done in hudson.remoting.Launcher, but it was missing in hudson.remoting.jnlp.Main. So it was not possible to start a Java Web Start agent in the insecure mode. In #205 @MattLud needs that.

How does it work now?

  • When -disableHttpsCertValidation is passed from Main, the JNLP Endpoint HTTPs cert verification is disabled.
  • JNLP agent ('Launcher.java') also sets the flag when -noCertificateCheck is passed

I also did some refactoring in order to prevent code duplication.

@reviewbybees @MattLud @Wadeck

@ghost
Copy link

ghost commented Nov 3, 2017

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

Copy link
Contributor

@Wadeck Wadeck left a comment

Choose a reason for hiding this comment

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

🐝 Small change proposals + questions, otherwise LGTM

@@ -242,6 +251,12 @@ public Engine createEngine() {
engine.setJarCache(new FileSystemJarCache(jarCache,true));
engine.setNoReconnect(noReconnect);
engine.setKeepAlive(!noKeepAlive);

if (disableHttpsCertValidation) {
LOGGER.log(WARNING, "Certificate validation for HTTPs endpoints is disabled");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be nice to make the rest of the calls also consistent. In that class there are currently 3 ways to create logs : LOGGER.fine(...), LOGGER.log(INFO,..., and LOGGER.log(Level.WARNING,...

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's do refactoring as a follow-up

httpsConnection.setHostnameVerifier(new NoCheckHostnameVerifier());
httpsConnection.setSSLSocketFactory(sslSocketFactory);
} catch (KeyManagementException | NoSuchAlgorithmException ex) {
System.err.println(String.format("Error setting disableHttpsCertValidation; %s", ex.getMessage()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to use System.err here instead of LOGGER ?

Copy link
Member Author

Choose a reason for hiding this comment

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

see above

((HttpsURLConnection) con).setSSLSocketFactory(sslSocketFactory);

if (con instanceof HttpsURLConnection) {
final HttpsURLConnection httpsConnection = (HttpsURLConnection) con;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the final does not add value here

Copy link
Member Author

Choose a reason for hiding this comment

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

It prevents somebody from modifying a field in the logic just in case

if (con instanceof HttpsURLConnection) {
final HttpsURLConnection httpsConnection = (HttpsURLConnection) con;
if (insecure) {
System.out.println(String.format("Insecure Status: %s", insecure));
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of LOGGER.fine / info should be preferred no ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so, but the file is full of stdout/stderr. @MattLud has followed the current implementation. I think it makes sense to stick to it for a while, but I will create a follow-up ticket to rework it

@oleg-nenashev
Copy link
Member Author

@reviewbybees done, I'd guess.
@Wadeck let me know if you are not fine with my response.
@rysteboe maybe you want to take a look as well

@oleg-nenashev
Copy link
Member Author

@reviewbybees done. Will resolve the merge conflict and release

@oleg-nenashev
Copy link
Member Author

I decided to exclude it from the 3.14 release, because I want to do more evaluation + maybe add documentation for this flag.

@@ -345,6 +351,10 @@ public void run() throws Exception {
jnlpArgs.add(c);
}
}
if (noCertificateCheck) {
//TODO: Rename option?
Copy link
Member Author

Choose a reason for hiding this comment

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

done

@oleg-nenashev
Copy link
Member Author

I tested it manually on the weekend. LGTM, will merge once the CI passes

@oleg-nenashev
Copy link
Member Author

Merging without squash, no plans to backport it

@oleg-nenashev oleg-nenashev merged commit 2d5624c into jenkinsci:master Nov 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants