How to SSL Your APIs in Mule ESB
You can use a self-signed certificate for your SSL API in Mule ESB to create an HTTPS-based API. Just add the certificate to the project and use SSL for API.
Join the DZone community and get the full member experience.
Join For FreeIn my previous blog, I showed you how to create a self-signed certificate for your SSL API.
In this blog, I will be showing how you can use this certificate in Mule ESB to create an 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 localserver.p12 to the project resources folder.
You can also create a subfolder and add your certificate to it, 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 an 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 this URL: https://localhost:4443/localapi.
When you call the above URL in your browser, be aware that you will be welcomed with an error message/warning by the browser saying that your connection isn't private.
Various browsers may use different words, but the root cause is same: the certificate you are using is not certified by a Certificate Authority (CA).
To overcome this error, you can go to Advanced, add the exception to your browser, and refresh the page. You will be able to see the response from the API.
This will be the output:
With this tutorial, you can see how to add HTTPS to your API in Mule ESB.
Watch the video tutorial below.
Opinions expressed by DZone contributors are their own.
Trending
-
How To Scan and Validate Image Uploads in Java
-
Building a Robust Data Engineering Pipeline in the Streaming Media Industry: An Insider’s Perspective
-
Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices
-
Building the World's Most Resilient To-Do List Application With Node.js, K8s, and Distributed SQL
Comments