Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions client/src/main/java/io/cloudsoft/winrm4j/client/WinRmClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private static void initializeClientAndService(WinRm winrm, WinRmClientBuilder b
bp.getRequestContext().put(AuthSchemeProvider.class.getName(), authSchemeRegistry);

AsyncHTTPConduit httpClient = (AsyncHTTPConduit) client.getConduit();

if (disableCertificateChecks) {
TLSClientParameters tlsClientParameters = new TLSClientParameters();
tlsClientParameters.setDisableCNCheck(true);
Expand All @@ -291,8 +291,19 @@ public X509Certificate[] getAcceptedIssuers() {
if (hostnameVerifier != null || sslSocketFactory != null || sslContext != null) {
TLSClientParameters tlsClientParameters = new TLSClientParameters();
tlsClientParameters.setHostnameVerifier(hostnameVerifier);
tlsClientParameters.setSSLSocketFactory(sslSocketFactory);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you meant to delete this line, to set the SSLSocketFactory!

tlsClientParameters.setSslContext(sslContext);
if(sslSocketFactory != null) {
if(sslSocketFactory.getDefaultCipherSuites()!=null && Arrays.asList(sslSocketFactory.getDefaultCipherSuites()).size()>0) {
tlsClientParameters.setCipherSuites(Arrays.asList(sslSocketFactory.getDefaultCipherSuites()));
Copy link
Member

Choose a reason for hiding this comment

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

Looking at how the tlsClientParameters.getCipherSuites is used, I'm not sure how this will get used:

  • HttpConduitConfigApplier.applyTlsClientParameters has no effect (code only used in else block where SSLSocketFactory was null)
  • HttpConduitConfigApplier.applyTlsClientParameters looks worrying: it adds to the list by calling p.getCipherSuites().add(...). That code is private so hopefully never called with the cipher suite you pass in - if it was, it would fail (because Arrays.asList returns a fixed-size list.
  • AsyncHTTPConduit.initializeSSLEngine: not sure what calls this.

}
Copy link
Member

Choose a reason for hiding this comment

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

Indents not aligned - is this a mix of tabs and spaces?

}
if(sslContext != null) {
tlsClientParameters.setSslContext(sslContext);
SSLParameters sslparams =sslContext.getDefaultSSLParameters();
Copy link
Member

Choose a reason for hiding this comment

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

This fails to compile for me because there is no import for SSLParameters.

//To make sure that the protocols are correctly set in the cxf context
if(sslparams.getProtocols() !=null && sslparams.getProtocols().length>0) {
tlsClientParameters.setSecureSocketProtocol(String.join(",", sslparams.getProtocols()));
Copy link
Member

Choose a reason for hiding this comment

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

Is this tested? The code looks surprising: the setSecureSocketProtocol is singular (talking about a single protocol in use), and you pass in a comma-separated list of protocols.

Is it documented anywhere that it can take a list?

Looking at how the code is subsequently used, it seems unlikely.

}
}
httpClient.setTlsClientParameters(tlsClientParameters);
}
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
Expand Down