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

FIPS support ! : by enhancing the winrm4j library to support TLS using Bo… #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EXTERNALCOREWORKS
Copy link

@EXTERNALCOREWORKS EXTERNALCOREWORKS commented May 9, 2019

…uncycastle (in addition to the common JKS) as the provider.

On winrm4j 0.6.1, new changes were introduced by your team:
Due to this issue: #80
Commits: #92
#93
Which allowed us to propagate the:

  • SSLContext (which mostly contains the protocols and as well as the security provider being defined, either JKS or bouncycastle or whatever, vital for FIPS compliance) and the
  • SSLSocketFactory (which contains the cipher suites to use, vital for FIPS compliance).
    So when we tried to do it by just passing over both the SSLContext and the SSLSocketFactory, we encountered the following open issue which we had already reported to your team: Cannot execute Winrm calls passing the SocketFactory and SSLContext to the WinRMTool.Builder #97

So in order to fix it:
*Based on the SSLSocketFactory (if present), we are just propagating out of it, the cipher suites to the Apache cxf TLSClientParameters class which later on will use such ciphers along with the provider for the secure communication.
*Based on the SSLContext, we are passing over the whole SSLContext to the TLSClientParameters, but we are also passing the protocols in the Apache CXF TLSClientParameters, so that the communication can be established successfully and FIPS compliant.

There could be better ways to propagate only those parameters (like allowing to pass the ciphers and protocols as new params besides the SSLContext and the SSLSocketFactory), but the fact that how it got implement in 0.6.1 was not stable enough is true, meaning that by incorporating this changes, the client application should only care to propagate both the SSLContext and the SSLSocketFactory and the winrm4j library will use only what's really needed :).
Hope you can absorb this changes that will benefit a lot your API, there is no single API similar like yours (like overthere or so) that actually supports FIPS, so this will be a great WIN for your software.

…uncycastle (in addition to the common JKS) as the provider.

On winrm4j 0.6.1, new changes were introduced by your team:
Due to this issue: cloudsoft#80
Commits: cloudsoft#92
cloudsoft#93
Which allowed us to propagate the:
* SSLContext (which mostly contains the protocols and as well as the security provider being defined, either JKS or bouncycastle or whatever, vital for FIPS compliance) and the 
* SSLSocketFactory (which contains the cipher suites to use, vital for FIPS compliance).   
So when we tried to do it by just passing over both the SSLContext and the SSLSocketFactory, we encountered the following open issue which we had already reported to your team: cloudsoft#97
So in order to fix it:
-Based on the SSLSocketFactory (if present), we are just propagating out of it, the cipher suites to the Apache cxf TLSClientParameters class which later on will use such ciphers along with the provider for the secure communication.
- Based on the SSLContext, we are passing over the whole SSLContext to the TLSClientParameters, but we are also passing the protocols in the Apache CXF TLSClientParameters, so that the communication can be established successfully and FIPS compliant.
There could be better ways to propagate only those parameters (like allowing to pass the ciphers and protocols as new params besides the SSLContext and the SSLSocketFactory), but the fact that how it got implement in 0.6.1 was not stable enough is true, meaning that by incorporating this changes, the client application should only care to propagate both the SSLContext and the SSLSocketFactory and the winrm4j library will use only what's really needed :).
Hope you can absorb this changes that will benefit a lot your API, there is no single API similar like yours (like overthere or so) that actually supports FIPS, so this will be a great WIN for your software.
@EXTERNALCOREWORKS EXTERNALCOREWORKS changed the title FIPS support ! : enhancing the winrm4j library to support TLS using Bo… FIPS support ! : by enhancing the winrm4j library to support TLS using Bo… May 9, 2019
@EXTERNALCOREWORKS
Copy link
Author

Hi @aledsage, would you mind to take a look at this Improvement PR ? Im willing to have this integrated in the product out of the box, benefiting a lot of customers that looks for FIPS compliance in their secure communications.

@EXTERNALCOREWORKS
Copy link
Author

Hi colleagues, Any updates on this one ?

@EXTERNALCOREWORKS
Copy link
Author

EXTERNALCOREWORKS commented Oct 4, 2019

Hi, any updates on this PR ?

Copy link
Member

@aledsage aledsage left a comment

Choose a reason for hiding this comment

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

Thanks for this. Some of the changes look ok but others don't compile and look like they wouldn't work. Can you give us an update how much you have tested these, and with what use-cases?

I'm tempted to take the change that sets the cipher suites, but not the change that sets the secureSocketProtocol. However, I'm very hesitant because I don't know what testing if any has been done with this (particularly given the code didn't even compile, and an important line had been accidentally deleted).

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.

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.

@@ -291,8 +291,19 @@ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) thr
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!

SSLParameters sslparams =sslContext.getDefaultSSLParameters();
//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.

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.

@aledsage
Copy link
Member

aledsage commented Dec 3, 2019

Quoting org.apache.cxf.configuration.jsse.TLSClientParameters:

    /**
     * This sets the SSLSocketFactory to use, causing all other properties of
     * this bean (and its superclass) to get ignored (this takes precendence).
     */
    public final void setSSLSocketFactory(SSLSocketFactory factory) {
        sslSocketFactory = factory;
    }

This suggests we do not need to extract cipher suites etc from the SSLSocketFactory to set it directly on the tlsClientParameters.

Does that contradict the behaviour you have seen @EXTERNALCOREWORKS ?

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.

2 participants