You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Michal Zerola (JIRA)" <ji...@apache.org> on 2013/03/13 15:14:13 UTC

[jira] [Comment Edited] (QPID-4636) SSL Client Authentication in Java broker

    [ https://issues.apache.org/jira/browse/QPID-4636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13601166#comment-13601166 ] 

Michal Zerola edited comment on QPID-4636 at 3/13/13 2:12 PM:
--------------------------------------------------------------

Hi Robbie,

I have uploaded a second patch covering some tests. Inside SSLContextFactoryTest.java we have added two tests, one for testing the peer manager truststore and second for the multiple managers truststores. Along with this I have created also the JKS file which needs to be placed into the test-profiles/test_resources/ssl/. This store contains the public keys from the client (stored under the alias app1 and app2 respectively).

The first test (testPeerStoreClientAuthentication) creates the new QpidPeersOnlyTrustManager and loads it with the new peerstore content. Then the client authentication is tested against this manager and should succeed (the client provides the chain of its certificate (app1) and since it is stored in the peer store all should pass). Later, the authentication is tested if the peer manager is loaded with the broker's store and doesn't contain the client's certificate. This test should fail.

The second test (testMultipleStoreClientAuthentication) creates the new QpidMultipleTrustManager and loads it with both peermanager and "regular" trustmanager. The client's authentication should succeed.

I have added also the check for the newly added attribute TrustStore.PEERS_ONLY into TrustStoreRecovererTest.java.

Do you think it is enough?

Michal
                
      was (Author: zer0):
    Hi Robbie,

I have uploaded a second patch covering some tests. Inside SSLContextFactoryTest.java we have added two tests, one for testing the peer manager truststore and second for the multiple managers truststores. Along with this I have created also the JKS file which needs to be placed into the test-profiles/test_resources/ssl/. This store contains the public keys from the client (stored under the alias app1 and app2 respectively).

The first test (testPeerStoreClientAuthentication) creates the new QpidPeersOnlyTrustManager and loads it with the new peerstore content. Then the client authentication is tested against this manager and should succeed (the client provides the chain of its certificate (app1) and since it is stored in the peer store all should pass). Later, the authentication is tested if the peer manager is loaded with the broker's store and doesn't contain the client's certificate. This test should fail.

The second test (testMultipleStoreClientAuthentication) creates the new QpidMultipleTrustManager and loads it with both peermanager and "regular" trustmanager. The client's authentication should succeed.

I have added also the into TrustStoreRecovererTest.java the check for the newly added attribute TrustStore.PEERS_ONLY.

Do you think it is enough?

Michal
                  
> SSL Client Authentication in Java broker
> ----------------------------------------
>
>                 Key: QPID-4636
>                 URL: https://issues.apache.org/jira/browse/QPID-4636
>             Project: Qpid
>          Issue Type: New Feature
>          Components: Java Broker, Java Common
>    Affects Versions: 0.21
>            Reporter: Michal Zerola
>            Assignee: Robbie Gemmell
>            Priority: Minor
>         Attachments: java_broker_peerstore.jks, ssl_new_trustmanager.patch, ssl_new_trustmanager_test.patch
>
>
> *Motivation:*
> The C++ broker implementation is based on the NSS library from Mozilla. The user creates a certificate database and configures the broker to load the database at start-up.  The NSS certificate database can store the private keys used by the broker as well as the public keys related to the connecting clients. The public keys can be divided into several groups - the keys of trusted CAs and the keys of trusted peers. The difference between the trusted CA and trusted peer is that the trusted CA allows logging in even to clients who have a certificate signed by the CA, while the peers allow logging in only to clients who have the certificate exactly matching the certificate loaded in the certificate database.
> The SSL Client Authentication in the Java broker is based on the Java JSSE implementation. The certificates are stored in the JKS format. The JKS format doesn't distinguish between trusted peers and trusted CA. Therefore all public keys behave as trusted CAs. As a result, the current implementation cannot be used together with self signed certificates. As we found out, there seems to be no support for the trusted peers in the JKS truststores.
> *Proposed solution:*
> The current configuration for the SSL Client Authentication supports only one truststore . We can add a second configuration entry which would allow to specify "peerstore" . When creating the SSL context, the existing truststore would be handled as it is handled today. If the "peerstore" is specified, the new TrustManager will be added to the SSL context.  The custom TrustManager will use the peerstore to verify the peers only as peers.  The client will pass the authentication if it is authenticated either with the original Trustmanager against the keystore or by the custom trust manager against the peer store.
> *Configuration and patch explanation:*
> The current configuration model for the broker (trunk) is based on JSON.  We have added two optional attributes (peerStorePath, peerStorePassword):
> {quote}
> …
>   "keyStorePath": "...",
>   "keyStorePassword": "123456",
>   "trustStorePath": "...",
>   "trustStorePassword": "123456",
>   {color:red}
>   "peerStorePath": "...",
>   "peerStorePassword": "123456",
>   {color}
> …
> {quote}
> Internally, the broker is prepared to handle multiple truststores, since it can store them in the collection. If the above new attributes were specified, the additional truststore is added into the collection (BrokerAdapter.java). A new truststore will have optional flag TrustStore.PEERS_ONLY set to True. The SSLContextFactory was extended for collection configuration. The Broker creates the SSLContext using the collection of truststores (either only single truststore or with a new peerstore). The SSLFactory parses the collection and depending on the TrustStore.PEERS_ONLY flag creates either regular JSSE trustmanager or uses a newly introduced one QpidPeersOnlyTrustManager.
> The new QpidPeersOnlyTrustManager works as a wrapper around standard JSSE trustmanager. When client connects, the check is delegated to the underlying JSSE verification and if it succeeds, the additional check is done, whether the peer’s certificate (in the chain index 0) is present in the keystore file. Only then the client is authenticated, otherwise the CertificateException is thrown.
> Since SSLContext.init method from the array of trustmanagers uses only the first one which is an instance of the X509TrustManager class, we have created also the extension. Otherwise, it would not be possible to use simultaneously trustmanager (JSSE implementation) and peermanager (our new implementation) because both implements X509TrustManager and only the first from the array would be considered. Therefore, we have introduced the QpidMultipleTrustManager which is doing nothing else but delegating the check to its underlying X509TrustManagers and only if all fails, the check itself fails. If some underlying manager succeeds, the check itself succeeds as well. This QpidMultipleTrustManager is loaded with truststore and peerstore manager and added into the array which is further passed to the SSLContext.init method.
> The implementation attached in the patch seems to be working fine and adds the above requirements for peers only truststore.  It is also backwards compatible- anyone without interest for peerstores will not see any change.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org