How does Mutual TLS (mTLS) enhance security by enforcing two-way certificate validation for enterprise integrations?
Answer
Basics: In ordinary TLS, only the server proves its identity. With mutual TLS (also called two-way SSL or mutual authentication), the client also proves it holds a certificate that the server trusts. This blocks callers that have stolen credentials but not the private key.
How it works:
- Inbound to Salesforce: Salesforce supports mutual authentication for API clients, which must be enabled by Salesforce Support. Clients connect on the mutual-auth endpoint (port 8443), and the org is given the trusted CA or client certificate. Users or integration profiles need the "Enforce SSL/TLS Mutual Authentication" permission. Verify the current setup path in Setup and docs.
- Outbound from Salesforce: upload or generate a certificate in Certificate and Key Management, then reference it in Apex with
req.setClientCertificateName('MyCert'), or in a Named Credential or External Credential configured with a client certificate. - The external server validates Salesforce's client certificate during the handshake, before any HTTP request is processed.
Advanced / deep dive: mTLS complements, but does not replace, OAuth. A common high-security design uses mTLS for transport trust plus OAuth JWT for identity and authorization. Certificates expire, so you need a rotation plan, because an expired certificate stops the integration. Private connectivity options, such as Private Connect, add network-level protection. Where an API gateway terminates TLS, make sure the gateway enforces the client certificate, since a gateway that accepts any certificate gives no security. Salesforce signs outbound calls with the org's certificate, so share only the public certificate with partners.
Code / config example:
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Partner_API/orders'); // Named Credential
req.setMethod('POST');
req.setClientCertificateName('Partner_mTLS_Cert'); // cert from Certificate and Key Management
req.setHeader('Content-Type', 'application/json');
req.setBody(JSON.serialize(payload));
HttpResponse res = new Http().send(req);
Hidden gotchas & must-remember points:
- Inbound mutual authentication is not on by default and needs enablement by Salesforce Support.
- Expired or rotated certificates are a leading cause of integration outages.
- mTLS authenticates the client system, not the user, so you still need OAuth or a session.
- Self-signed certificates can be used, but the other side must explicitly trust them.
- Certificate names in Apex must match exactly, and sandbox refresh does not always carry certificates over.
- It does not replace IP restrictions or permission controls.
Best practice: Combine mTLS with OAuth, automate certificate rotation, and monitor expiry dates.