Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: changes related to https://github.com/wso2/docs-apim/issues/1551
Warning

This is available only as a  WUM update and is effective from 22nd October 2018 (2018-10-22). For more information on updating WSO2 API Manager, see Updating WSO2 API Manager.

...

  1. Create an API.
  2. Edit the API and navigate to the Manage tab.
  3. Select Mutual SSL under API Security.

    Note

    You can select both OAuth2 and Mutual SSL options. This means that the user can access the API using a valid OAuth2 token or using a valid client certificate. When OAuth2 and Mutual SSL are both enabled, Mutual SSL authentication will have a higher priority than OAuth2 as explained as follows:

    API SecurityUser's ResponseOutcome
    OAuth2Mutual SSL

    OAuth2
    token

    Mutual SSL
    Certificate

    EnabledEnabledSentSent
    • Initially, the Mutual SSL certificate is validated. If the validation is successful, the OAuth2 token is ignored.
    • If the Mutual SSL certificate fails, the OAuth2 token is validated, but if the OAuth2 token fails as well, the API call will fail.
    EnabledEnabledNot sentSent
    • The Mutual SSL certificate is validated. If the validation fails, the API call will fail.
    EnabledEnabledSentNot sent
    • The OAuth2 token is validated. If the validation fails, the API call will fail.
  4. Click Manage Certificates to upload a new client certificate. Select Add New Certificate.


    Insert excerpt
    Dynamic SSL Certificate Installation
    Dynamic SSL Certificate Installation
    nopaneltrue

    Info

    After configuring, the certificate will be added to the Gateway nodes which are defined under the Environments in api-manager.xml. In a clustered setup, as gateway configurations are identical, sync the <API-M_HOME>/repository/resources/security/listenerprofiles.xml and <API-M_HOME>/repository/resources/security/client-truststore.jks among the gateway nodes. After the configured interval, the synapse transport will be reloaded in all the gateway nodes.

  5. Provide an alias and public certificate. Select the tier that should be used to throttle out the calls using this particular client certificate and click Upload.
    Image Modified

    Save and Publish the API

Invoke an API secured with Mutual SSL from the API Store

  1. Note
    title

...

Add the relevant certificate to your browser according to your private certificate.

  1. Invoke an API from the API Store.
  2. When you click Execute the browser will send a prompt similar to the one shown below. Select the corresponding certificate for the API.
    Image Removed

Differences compared to APIs secured over OAuth 2.0

Listed below are the known differences in features when APIs are secured using Mutual SSL compared to OAuth 2.0.

...

Comparative to subscription level rate limiting policies, with Mutual SSL what you get is rate limiting policies by certificate. API developers can define the rate limit to be applied by each accepted certificate.

...

In the case of Mutual SSL since there are no access tokens involved, the concept of resource security "type" for API resources doesn't apply. Security "type" in API resources are based on whether the access token belongs to an application or an end-user. In the case of Mutual SSL the certificate is issued to the client application.

...

  1. If you are marking the API as the Default Version

    To make Mutual SSL work with Default APIs follow the below steps before following step 6.

    1. Navigate to the <API-M_HOME>/repository/resources/api_templates/default_api_template.xml file in the Publisher node.

    2. Add the following handler to the top of the set of handlers defined inside <handlers> config.

      Code Block
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.common.MutualSSLCertificateHandler"/>


      A sample default_api_template.xml file with the above would look like below.

      Code Block
      <api xmlns="http://ws.apache.org/ns/synapse" name="$!apiName" context="$!apiContext" transports="$!transport">
        ...
        <handlers>
            <handler class="org.wso2.carbon.apimgt.gateway.handlers.common.MutualSSLCertificateHandler"/>
            <handler class="org.wso2.carbon.apimgt.gateway.handlers.common.SynapsePropertiesHandler"/>
            <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
               <property name="apiImplementationType" value="ENDPOINT"/>
            </handler>
        </handlers>
  2. Save and Publish the API


Invoke an API secured with Mutual SSL from the API Store

Note
titleBefore you begin...

Add the relevant certificate to your browser according to your private certificate.

  1. Invoke an API from the API Store.
  2. When you click Execute the browser will send a prompt similar to the one shown below. Select the corresponding certificate for the API.
    Image Added

Differences compared to APIs secured over OAuth 2.0

Listed below are the known differences in features when APIs are secured using Mutual SSL compared to OAuth 2.0.

  • Comparative to subscription level rate limiting policies, with Mutual SSL what you get is rate limiting policies by certificate. API developers can define the rate limit to be applied by each accepted certificate.

  • In the case of Mutual SSL since there are no access tokens involved, the concept of resource security "type" for API resources doesn't apply. Security "type" in API resources are based on whether the access token belongs to an application or an end-user. In the case of Mutual SSL the certificate is issued to the client application.

  • Fine grained authorization has to be done using message mediation policies. Since mutual TLS does not have a concept similar to that of OAuth 2.0 scopes, features such as role-based-access-control for example would need to be achieve using alternatives similar to message mediation policies.

Handling MTLS when SSL is terminated by the load balancer/reverse proxy

When SSL Termination of API requests happens at the load balancer/reverse proxy, the following prerequisites need to be met from the load balancer.

The below diagram shows how MutualSSL works in such an environment.

Image Added

By default, the WSO2 API Manager retrieves the client certificate from the X-WSO2-CLIENT-CERTIFICATE HTTP header. In order to change the header,

  1. Navigate to the <API-M_HOME>/repository/conf/api-manager.xml file in Gateway node.

  2. Put the following under <APIManager> section.

    Code Block
    <APIManager>
    	...
       <MutualSSL> 
           <ClientCertificateHeader>X-WSO2-CLIENT-CERTIFICATE</ClientCertificateHeader> 
           <!-- This property need to be true if MutualSSL connection established between load balancer and gateway.--> 
          <EnableClientCertificateValidation>false</EnableClientCertificateValidation> 
       </MutualSSL>
  3. Restart the API Manager.


Note

By default for Mutual SSL feature in Gateway, the WSO2 API Manager reload the new certificates from truststore into memory within an interval of 10mins. In order to change the reload interval,

  1. Navigate to the <API-M_HOME>/repository/conf/api-manager.xml file in Gateway node.
  2. Put the following under <APIManager> section. Add the reload interval in seconds inside <Period> configuration.

    Code Block
    <APIManager>
    	...
        <CertificateReLoaderConfiguration>
           <Period>10</Period>
        </CertificateReLoaderConfiguration>
  3. Restart the API Manager.