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

Fix SSLHandshakeException while closing HTTPConduit #25148

Merged
merged 2 commits into from
May 2, 2023

Conversation

sawadood
Copy link
Contributor

@sawadood sawadood commented May 1, 2023

fixes #24986

@sawadood sawadood self-assigned this May 1, 2023
@sawadood
Copy link
Contributor Author

sawadood commented May 1, 2023

#spawn.fullfat.buckets=com.ibm.ws.jaxws.2.2.webcontainer_fat,com.ibm.ws.jaxws.2.2.webcontainer_fat_extended,com.ibm.ws.jaxws.cdi_fat,com.ibm.ws.jaxws.clientcontainer_fat,com.ibm.ws.jaxws.ejb_fat,com.ibm.ws.jaxws.X.wsat_fat,io.openliberty.xmlws.4.0.internal_fat,io.openliberty.ws.jaxws.global.handler.internal_fat,io.openliberty.jaxws.security_fat.ssl,io.openliberty.jaxws.security_fat.1,io.openliberty.jaxws.security_fat,com.ibm.ws.wssecurity_fat.wsscxf.1,com.ibm.ws.wssecurity_fat.wsscxf.2,com.ibm.ws.wssecurity_fat.wsscxf.3, com.ibm.ws.wssecurity_fat.wsscxf.4,com.ibm.ws.wssecurity_fat.wsscxf.saml.1,com.ibm.ws.wssecurity_fat.wsscxf.saml.2,com.ibm.ws.wssecurity_fat.wsscxf.saml.3,com.ibm.ws.wssecurity_fat.wsscxf.saml.4,com.ibm.ws.wssecurity_fat.wsscxf.saml.5,com.ibm.ws.wssecurity_fat.wsscxf.saml.6

@sawadood sawadood requested a review from neuwerk May 1, 2023 14:29
@sawadood
Copy link
Contributor Author

sawadood commented May 1, 2023

#build
#spawn.fullfat.buckets=com.ibm.ws.jaxws.2.2.webcontainer_fat,com.ibm.ws.jaxws.2.2.webcontainer_fat_extended,com.ibm.ws.jaxws.cdi_fat,com.ibm.ws.jaxws.clientcontainer_fat,com.ibm.ws.jaxws.ejb_fat,com.ibm.ws.jaxws.X.wsat_fat,io.openliberty.xmlws.4.0.internal_fat,io.openliberty.ws.jaxws.global.handler.internal_fat,io.openliberty.jaxws.security_fat.ssl,io.openliberty.jaxws.security_fat.1,io.openliberty.jaxws.security_fat,com.ibm.ws.wssecurity_fat.wsscxf.1,com.ibm.ws.wssecurity_fat.wsscxf.2,com.ibm.ws.wssecurity_fat.wsscxf.3, com.ibm.ws.wssecurity_fat.wsscxf.4,com.ibm.ws.wssecurity_fat.wsscxf.saml.1,com.ibm.ws.wssecurity_fat.wsscxf.saml.2,com.ibm.ws.wssecurity_fat.wsscxf.saml.3,com.ibm.ws.wssecurity_fat.wsscxf.saml.4,com.ibm.ws.wssecurity_fat.wsscxf.saml.5,com.ibm.ws.wssecurity_fat.wsscxf.saml.6,com.ibm.ws.wsat_fat.2,com.ibm.ws.wsat_fat.3,com.ibm.ws.wsat_fat.4,com.ibm.ws.wsat_fat.5,com.ibm.ws.wsat_fat.6,com.ibm.ws.wsat_fat.7,com.ibm.ws.wsat_fat.db,com.ibm.ws.wsat.common_fat,com.ibm.ws.wsat.concurrent_fat,com.ibm.ws.wsat.migration_fat.1,com.ibm.ws.wsat.migration_fat.2,com.ibm.ws.wsat.migration_fat.3,com.ibm.ws.wsat.migration_fat.4,com.ibm.ws.wsat.migration_fat.5,com.ibm.ws.wsat.recovery_fat.lps,com.ibm.ws.wsat.recovery_fat.multi.1,com.ibm.ws.wsat.recovery_fat.multii.2,com.ibm.ws.wsat.recovery_fat.multii.3,com.ibm.ws.wsat.recovery_fat.multii.4,com.ibm.ws.wsat.recovery_fat.single.1,com.ibm.ws.wsat.recovery_fat.single.2,com.ibm.ws.jaxws.2.2.webcontainer_fat,com.ibm.ws.jaxws.2.2.webcontainer_fat_extended,com.ibm.ws.jaxws.cdi_fat,com.ibm.ws.jaxws.clientcontainer_fat,com.ibm.ws.jaxws.ejb_fat,com.ibm.ws.jaxws.X.wsat_fat,com.ibm.ws.javaee.dd.model_fat,com.ibm.ws.microprofile.rest.client.FT_fat,com.ibm.ws.microprofile.rest.client11_fat_tck,com.ibm.ws.microprofile.rest.client12_fat_tck,com.ibm.ws.microprofile.rest.client13_fat_tck,com.ibm.ws.microprofile.rest.client14_fat_tck,com.ibm.ws.microprofile.rest.client_fat,com.ibm.ws.microprofile.rest.client_fat_tck

@LibbyBot
Copy link

LibbyBot commented May 1, 2023

Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_sWlPYOgrEe2D8Kk7c5d7Ig

Target locations of links might be accessible only to IBM employees.

@sawadood sawadood requested a review from BerksanAtes May 1, 2023 19:26
@LibbyBot
Copy link

LibbyBot commented May 2, 2023

The build sawadood-25148-20230501-0831
https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_sWlPYOgrEe2D8Kk7c5d7Ig
completed and has errors or failures.

For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_sWlPYOgrEe2D8Kk7c5d7Ig

@neuwerk neuwerk requested a review from WhiteCat22 May 2, 2023 11:37
@sawadood
Copy link
Contributor Author

sawadood commented May 2, 2023

Personal build has 11 failures, all these failures have the same error ""invalid test bucket"" and not related to my fix.

Copy link
Member

@BerksanAtes BerksanAtes left a comment

Choose a reason for hiding this comment

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

It looks great! Especially, I believe added traces will helps us tremendously!!

@sawadood
Copy link
Contributor Author

sawadood commented May 2, 2023

#run-libby-bot

@sawadood
Copy link
Contributor Author

sawadood commented May 2, 2023

Tested this fix locally also and did not find any issues.

@sawadood sawadood merged commit 0e60434 into OpenLiberty:integration May 2, 2023
@LibbyBot
Copy link

LibbyBot commented May 2, 2023

Code analysis and actions

DO NOT DELETE THIS COMMENT.
  • 4 product code files were changed.
  • Please describe in a separate comment how you tested your changes.


// Liberty start
boolean isRestMessage =
PropertyUtils.isTrue(message.getExchange().get(org.apache.cxf.message.Message.REST_MESSAGE));
Copy link
Member

Choose a reason for hiding this comment

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

Can you confirm that org.apache.cxf.rest.message is present on MP Rest Client requests in addition to vanilla JAX-RS request please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have tested that org.apache.cxf.rest.message is present on MP REST client requests.

}

if (socketFactory != null) {
LOG.fine("SSL socketFactory: " + socketFactory.getClass().getCanonicalName()); // Liberty Change
Copy link
Member

Choose a reason for hiding this comment

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

// Liberty Change End

LOG.fine("No trustManagers set on tlsClientParameters, so use Liberty's DefaultSSLSocketFactory");
socketFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
}
// Liberty Change End
Copy link
Member

Choose a reason for hiding this comment

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

Move this // Liberty Change End to after line 178

verifier = new AllowAllHostnameVerifier();
} else if (!performHostNameVerification) { // Liberty Change Start
LOG.fine("TS012061109: performHostNameVerification is false, setting verifier to AllowAllHostnameVerifier.");
Copy link
Member

Choose a reason for hiding this comment

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

Remove TS012061109

}
});
performHostNameVerification = b.booleanValue();
LOG.fine("TS012061109: Property com.ibm.ssl.performURLHostNameVerification is set to: " + performHostNameVerification);
Copy link
Member

Choose a reason for hiding this comment

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

remove TS012061109

@WhiteCat22
Copy link
Member

@sawadood I don't know why it's not allowing my to block the merge with "Request Changes", but I would like to see my comments addressed before you merge, thanks!

@@ -393,6 +409,7 @@ protected InputStream getInputStream() throws IOException {
in = connection.getInputStream();
} catch (IOException ex) {
// ignore
LOG.fine("Ignoring unexpected exception in getInputStream(): " + ex); // Liberty Change
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me that this code section might be incorrect (but would not cause a problem in most cases). They are attempting to get the "Error Stream". Shouldn't the if check here be if (in != null)?

Also, I'd suggest changing your log message to "Ignoring unexpected exception in getInputStream() when an error stream is present: "

Copy link
Member

@jim-krueger jim-krueger left a comment

Choose a reason for hiding this comment

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

Looks good. Just a couple comments/suggestions.

if (HTTPS_URL_PROTOCOL_ID.equals(url.getProtocol())) {

if (tlsClientParameters == null) {
LOG.fine("tlsClientParameters is NULL, get new"); // Liberty Change
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Change get to create


// Liberty Change Start
if (verifier != null) {
LOG.fine("Hostname verifier obtained from SSLUtils.getHostnameVerifier: " + verifier.getClass().getCanonicalName());
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Remove the if check and change the line to the following so you'll know if it is null or not more easily:
LOG.fine(""Hostname verifier obtained from SSLUtils.getHostnameVerifier: " + (verifier==null? "null": verifier.getClass().getCanonicalName()));

Copy link
Member

Choose a reason for hiding this comment

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

I think we should leave the if check, but only print a message if the verifier is null.

}

if (tlsClientParameters != null) {
LOG.fine("isDisableCNCheck value in tlsClientParameters: " + tlsClientParameters.isDisableCNCheck());
Copy link
Member

Choose a reason for hiding this comment

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

same suggestion here as above.

HttpsURLConnection conn = (HttpsURLConnection) connection;
// Liberty Change Start
if (verifier != null) {
LOG.fine("Setting Hostname verifier to: " + verifier.getClass().getCanonicalName());
Copy link
Member

Choose a reason for hiding this comment

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

same comment

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.

SSLHandshakeException occurs while closing HTTPConduit
5 participants