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

Add insecure flag to allow bypassing SSL hostname verification and cert checks #205

Merged
merged 1 commit into from
Nov 20, 2017

Conversation

MattLud
Copy link
Contributor

@MattLud MattLud commented Oct 17, 2017

Initial proposal - Let me know what sort of unit tests you'd like to see or if you want the whitespace changes reverted.

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Just a formatting things for now. Will review the logic later, didn't get to it.




public boolean isInsecure() {
Copy link
Member

Choose a reason for hiding this comment

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

Methods should not be listed before fields. It will confuse other contributors

Copy link
Member

Choose a reason for hiding this comment

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

New API methods also should be documented

@@ -80,6 +89,16 @@

private String tunnel;

private boolean insecure;

public boolean isInsecure() {
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -141,7 +160,7 @@ public void setTunnel(String tunnel) {
public JnlpAgentEndpoint resolve() throws IOException {
IOException firstError = null;
for (String jenkinsUrl : jenkinsUrls) {

Copy link
Member

Choose a reason for hiding this comment

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

Please do not do unrelated whitespace changes. It may cause undesired merge conflicts

@MattLud
Copy link
Contributor Author

MattLud commented Oct 20, 2017

Ok - repushed with amended commit.

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

There are just minor formatting issues, I will fix them after the merge

@@ -156,6 +153,23 @@ public void run() {



/**
* Determines if JNLPAgentEndpointResolver will not perform certificate validation
* @return
Copy link
Member

Choose a reason for hiding this comment

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

Please do not keep empty javadoc tags.
@since TODO would be useful

* Sets if JNLPAgentEndpointResolver will not perform certificate validation
*
* @param insecure
*/
Copy link
Member

Choose a reason for hiding this comment

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

same, also strange line breaks

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 improvement proposals

@@ -92,6 +89,10 @@
usage="If the connection ends, don't retry and just exit.")
public boolean noReconnect = false;

@Option(name="-insecure",
usage="Ignore SSL validation errors - use as a last resort only.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly the type of comment I would like to see more often on such option :) 👍

* @return if insecure, endpoint check is ignored
*/

public boolean isInsecure() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird line break +1

if (con instanceof HttpsURLConnection && sslSocketFactory != null) {

if (insecure && con instanceof HttpsURLConnection) {
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.

Better to use a logger instead of System.out.println.

Copy link
Member

Choose a reason for hiding this comment

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

It requires a wider refactoring, the option is being used in other places

};

((HttpsURLConnection) con).setHostnameVerifier(allHostsValid);
((HttpsURLConnection) con).setSSLSocketFactory(sslSocketFactory);
Copy link
Contributor

Choose a reason for hiding this comment

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

Double casting could be avoided by using a local variable just above like

HttpsURLConnection httpsCon = (HttpsURLConnection) con;
httpsCon.setHostnameVerifier(allHostsValid);
httpsCon.setSSLSocketFactory(sslSocketFactory);

return true;
}
};
((HttpsURLConnection) con).setHostnameVerifier(allHostsValid);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto double cast

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

After some deeper review I cannot accept this implementation. I will create a follow-up PR with some refactoring and comments

@MattLud
Copy link
Contributor Author

MattLud commented Nov 3, 2017 via email

@oleg-nenashev
Copy link
Member

@MattLud Created #210

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

Successfully merging this pull request may close these issues.

3 participants