DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Create Proxy Application for Mule APIs
  • MuleSoft OAuth 2.0 Provider: Password Grant Type
  • Secure Your Frontend: Practical Tips for Developers
  • Optimizing MuleSoft Performance With HikariCP: A Complete Guide

Trending

  • Artificial Intelligence, Real Consequences: Balancing Good vs Evil AI [Infographic]
  • From Zero to Production: Best Practices for Scaling LLMs in the Enterprise
  • MySQL to PostgreSQL Database Migration: A Practical Case Study
  • Integration Isn’t a Task — It’s an Architectural Discipline
  1. DZone
  2. Software Design and Architecture
  3. Security
  4. How to Set up OAuth JWT Flow and mTLS in the Salesforce Connector for a MuleSoft App

How to Set up OAuth JWT Flow and mTLS in the Salesforce Connector for a MuleSoft App

Walk through the required steps to set up mutual TLS between the Mule app and the Salesforce Connected App we created in the first post of this series.

By 
GONZALO MARCOS user avatar
GONZALO MARCOS
·
Oct. 14, 24 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
3.9K Views

Join the DZone community and get the full member experience.

Join For Free

In the first part of this series, we set up a Mule app and a Salesforce Connected app for the OAuth JWT bearer token flow. In this second part, we’ll go through the required steps to set up mutual TLS between the Mule app and the Salesforce Connected App we created in that first post.

Create a New Profile in Salesforce for mTLS

  • If the Profile you used in Part 1 of this guide (linked earlier) is the definitive one that you’ll use for this Mule app, skip this step.
  • Go to Setup > Profiles.
  • Click on New Profile.

Click on New Profile

  • Pick up an existing profile to clone from and give it a name. We’ll clone the System Administrator profile in this example, just for the purpose of the demonstration. As a best practice, pick up an Integration User Profile or an existing profile associated with the Named Users you’re planning to use from the Mule App. 

Clone profile

  • Click Save.
  • Go back to the Profile Overview page, scroll down to the System section, and click on System Permissions.

System Permissions

  • Add the Enforce SSL/TLS Mutual Authentication from the list of permissions. If you don’t see this option you need to contact Salesforce to enable the feature.

Enforce SSL/TLS Mutual Authentication

  • Assign a user to the new profile. That would be the user (or users) that we’ll use in the Mule app. Depending on your use case it can be a Named User or an Integration User.
  • Go to Setup > Users and click on your selected user.
  • In the User page click on Edit and change the Profile to our newly created profile for mTLS.

n the User page click on Edit and change the Profile to our newly created profile for mTLS.

  • Click Save.

(Optional) Create a Connected App Associated With This Profile

  • Skip this step if you’ll be using the Connected App created in Part 1.
  • If not, follow the steps in Part 1 to create a new Connected App and the configuration of the Mule app to use OAuth JWT as auth flow in the salesforce connector.

Set Up a Mutual Authentication Certificate

  • Go to Setup > Certificate and Key Management and click on the Upload Mutual Authentication Certificate within the Mutual Authentication Certificates section. If you don’t see this section in the Certificate and Key Management page you’ll need to open a support ticket with Salesforce to get this feature enabled in your org.

Mutual Authentication Certificates

  • Provide a name and a label for your certificate and then add the certificate. Remember that self-signed certificates are not valid for mTLS. Here, we’ll be uploading the certificate with the public key for your user(s) in the Mule App. The corresponding private key will be stored in the Mule app.

Provide a Label, Unique Name, and Certificate

  • You must upload a PEM-encoded client certificate. You only need to upload the client certificate itself; do not upload a certificate chain.

Configuration of the Mule App

In this section, we’ll continue with the mule app created in Part 1 of this guide. Refer to that part if you need to start with a new mule application.

Upload the Key Store to the Mule Project

  • Go to your Mule app in Anypoint Studio.
  • If you haven’t done it, create a key store that will include your private/public key pair. You can do it as a JKS, PKCS12 or JCEKS. All of them are valid. In this guide, we’ll use JKS. You can use any tool such as Key Store Tool.
  • Right-click on the project name and select Show In > System Explorer. That should open an explorer window in the main folder of our project. 

Select Show In > System Explorer

  • From there, go to Resources and upload the jks file of our keystore.
  • Back to Studio: If you right-click again in the name of our project and click Refresh, we should see our keystore under the src/main/resources folder.

Our keystore under the src/main/resources folder

Set up the Key Store in the Salesforce Configuration Element

  • Next, from the canvas, go to the Global Elements tab and open the Salesforce Config element.
  • Go to the Security Tab and select the Edit Inline option in the TLS configuration dropdown (or select global reference if you prefer to set this configuration as a Global Configuration Element).
  • In this tab, we need to provide the Key Store for the User(s) that will be accessing our Salesforce Connected App via the Salesforce connector in our mule app. The key store has to contain the private key corresponding to the public key and certificate that we uploaded in our previous step in Salesforce as a Mutual Authentication Certificate.
    • Select the type of Key Store; in this guide, it is JKS.
    • The path within the app of the key store: The root path corresponds to the src/main/resources folder in our Mule Project. In our example, we uploaded the key store in that root folder
    • Provide the password for your keystore.

Key Store Configuration

  • Test the connection:

Test the connection

  • Run the app in Studio.
  • Test the app and verify that your Salesforce query is successful.

Video

You can also follow this video tutorial from our Mulesoft Ambassador, Stefano Bernardini:


MULE MuleSoft JWT (JSON Web Token) security

Opinions expressed by DZone contributors are their own.

Related

  • Create Proxy Application for Mule APIs
  • MuleSoft OAuth 2.0 Provider: Password Grant Type
  • Secure Your Frontend: Practical Tips for Developers
  • Optimizing MuleSoft Performance With HikariCP: A Complete Guide

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!