|
| 1 | +# Enabling Mutual SSL |
| 2 | + |
| 3 | +### How it works |
| 4 | + |
| 5 | +In contrast to the usual one-way SSL authentication where a client |
| 6 | +verifies the identity of the server, in mutual SSL the server validates |
| 7 | +the identity of the client so that both parties trust each other. This |
| 8 | +builds a system that has a very tight security and avoids any requests |
| 9 | +made from the client to provide the username/password, as long as the |
| 10 | +server is aware of the certificates that belong to the client. |
| 11 | + |
| 12 | +Before the process begins, the client and servers certificates are stored |
| 13 | +in there relevant `keystores` . In the case of JAVA |
| 14 | +they are `jks` files. Let's take a look at where the |
| 15 | +JKS files are saved: |
| 16 | + |
| 17 | +- WSO2 Identity Server certificates are stored in the |
| 18 | + `<IS-HOME>/repository/resources/security/wso2carbon.jks` file. |
| 19 | +- Server side certificates are stored in the |
| 20 | + `<IS-HOME>/repository/resources/security/clienttruststore.jks` file. |
| 21 | + |
| 22 | +These certificates are signed and issued by a certificate authority that |
| 23 | +allows both the client and server to communicate freely. Now let's look |
| 24 | +at how it works: |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +1. The Client attempts to access a protected resource and the SSL/TSL |
| 29 | + handshake process begins. |
| 30 | +2. The Server presents its certificate, which is the |
| 31 | + `server.crt` according to our example as shown |
| 32 | + above. |
| 33 | +3. The Client takes this certificate and asks the certificate issued |
| 34 | + authority for the authenticity and validity of the certificate. |
| 35 | +4. If the certificate is valid, the client will also provide its |
| 36 | + certificate to the server. |
| 37 | +5. The Server takes this certificate and asks the certificate issued |
| 38 | + authority for the authenticity and validity of the certificate. |
| 39 | +6. The Client is granted access to the resource it was trying to access |
| 40 | + earlier. |
| 41 | + |
| 42 | +### Enabling Mutual SSL in the WSO2 IS |
| 43 | + |
| 44 | +1. Open the |
| 45 | + `<IS_HOME>/repository/conf/tomcat/catalina-server.xml` |
| 46 | + file and ensure that the `certificateVerification` attribute |
| 47 | + in the `SSLHostConfig` tag under `https` connector is set to |
| 48 | + `want` as shown below. This is done to |
| 49 | + disable the certificate authentication on certain occasions (like |
| 50 | + when working on mobile apps). This makes two-way SSL authentication |
| 51 | + optional. Set the value as `require` to make two-way SSL authentication mandatory. |
| 52 | + |
| 53 | + ``` java |
| 54 | + certificateVerification="want" |
| 55 | + ``` |
| 56 | + If not add the following configuration to `<IS_HOME>/repository/conf/deployment.toml` |
| 57 | + |
| 58 | + ```toml |
| 59 | + [transport.https.sslHostConfig.properties] |
| 60 | + certificateVerification = "want" |
| 61 | + ``` |
| 62 | + |
| 63 | +2. Open the |
| 64 | + `deployment.toml` |
| 65 | + file and add the following configuration to enable the |
| 66 | + Mutual SSL Authenticator. |
| 67 | + |
| 68 | + ``` toml |
| 69 | + [admin_console.authenticator.mutual_ssl_authenticator] |
| 70 | + enable = true |
| 71 | + |
| 72 | + [admin_console.authenticator.mutual_ssl_authenticator.config] |
| 73 | + WhiteList = "" |
| 74 | + ``` |
| 75 | + |
| 76 | +3. For mutual SSL authentication, the public certificate of the WSO2 |
| 77 | + Identity Server has to be imported to the truststore of the client |
| 78 | + and the public certificate of the client has to be imported to the |
| 79 | + client-truststore of Identity Server. |
| 80 | + |
| 81 | + !!! example "Sample commands" |
| 82 | + |
| 83 | + The following two commands are examples if you are using the |
| 84 | + keystore and client-truststore of the Identity Server itself for the |
| 85 | + client. This is executed from the |
| 86 | + `<IS_HOME>/repository/resources/security` |
| 87 | + directory. |
| 88 | + |
| 89 | + ``` java |
| 90 | + keytool -export -alias wso2carbon -file carbon_public2.crt -keystore wso2carbon.jks -storepass wso2carbon |
| 91 | + ``` |
| 92 | + |
| 93 | + ``` java |
| 94 | + keytool -import -trustcacerts -alias carbon -file carbon_public2.crt -keystore client-truststore.jks -storepass wso2carbon |
| 95 | + ``` |
0 commit comments