Skip to content

Use the correct alert depending on the CertificateException when usin…#6046

Closed
normanmaurer wants to merge 1 commit into
4.1from
ssl_alert
Closed

Use the correct alert depending on the CertificateException when usin…#6046
normanmaurer wants to merge 1 commit into
4.1from
ssl_alert

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

…g OpenSslEngine

Motivation:

We tried to detect the correct alert to use depending on the CertificateException that is thrown by the TrustManager. This not worked all the time as depending on the TrustManager implementation it may also wrap a CertPathValidatorException.

Modification:

  • Try to unwrap the CertificateException if needed and detect the right alert via the CertPathValidatorException.
  • Add unit to verify

Result:

Send the correct alert depending on the CertificateException when using OpenSslEngine.

@normanmaurer normanmaurer added this to the 4.0.43.Final milestone Nov 19, 2016
@normanmaurer normanmaurer self-assigned this Nov 19, 2016
@normanmaurer
Copy link
Copy Markdown
Member Author

@Scottmitch PTAL

…g OpenSslEngine

Motivation:

We tried to detect the correct alert to use depending on the CertificateException that is thrown by the TrustManager. This not worked all the time as depending on the TrustManager implementation it may also wrap a CertPathValidatorException.

Modification:

- Try to unwrap the CertificateException if needed and detect the right alert via the CertPathValidatorException.
- Add unit to verify

Result:

Send the correct alert depending on the CertificateException when using OpenSslEngine.
}
}

// Its a bit hacky to verify against the message that is part of the exception but there is no other way
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agreed it is hacky ... maybe we can just validate the exception type for now and enhance later if JDK provides us with more granular exceptions, or a more reliable error code indicator?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nope as the exception type was the same before, so let us keep it

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch Nov 19, 2016

Choose a reason for hiding this comment

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

this test may be JDK dependent though right? Also what about exception msg localization?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah... maybe just use assumeTrue?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

http://junit.sourceforge.net/javadoc/org/junit/Assume.html

A set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed assumption does not mean the code is broken, but that the test provides no useful information.

The test is still useful if we can't verify the exception text ... just that we can't verify the conditions at the granularity that we would like. If the text doesn't match we really don't know what is going on (e.g. text changed but still same logical condition). If its not reliable maybe we should just not check for it at all. I have also checked exception text in the past bcz of lack of more expressive exceptions ... but its not portable and I wouldn't mind taking it out now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am on the fence here... as without the message check it passes also without the fix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok your call. Unfortunate that we don't have a more reliable way to verify. Can we get the alert code from an OpenSSL API maybe?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Scottmitch let me just pull it in as it is then... there is no way atm.

@normanmaurer
Copy link
Copy Markdown
Member Author

Cherry-picked into 4.1 (9b7fb2f) and 4.0 (139af2a)

@normanmaurer normanmaurer deleted the ssl_alert branch November 21, 2016 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants