In my previous blog I showed you how to create a self signed certificate for your SSL api. you can watch the video at https://youtu.be/lIedlZ7BRk8 and read the blog here https://echarish.wordpress.com/2017/03/19/self-sign-https-certificate-video/
In this blog I will be showing how you can use this certificate in mule ESB to create a https based api.

Adding certificate to project
Let’s add the certificate to our project src/main/resources folder, we will be using this to add TLS/SSL to our HTTP endpoint listener

As shown in the image, we have added the localserver.p12 to the project resources folder.
You can also create sub-folder and add your certificate to the sub-folder but make sure you use the proper location of certificate while adding it to the HTTP listener in your config file.
Using SSL for API
once you are done adding the certificate to your project resources, let’s drag and drop a HTTP listener to your mule config file and start configuring the listener and adding the certificate detail to your listener.

After adding the certificate detail to your listener add a set payload to get the response in your browser.
We will be calling our API at URL
https://localhost:4443/localapi
When you call the above url in your browser, be aware that you will be welcomed with a error message/warning by the browser saying
Your Connection is not Private
Various browser may use different words but the root cause is same, the root cause is that the certificate you are using is not certified by a CA, you can read more about CA https://en.wikipedia.org/wiki/Certificate_authority

To overcome this error you can go to advance and add the exception to your browser and than refresh the page and you will be able to see the response from the api.

one done below will be the output.

With this you can see how to add HTTPS to you API in mule esb.
Video [https://youtu.be/4Wtu8uQWGPo]
