> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wiremock.io/llms.txt
> Use this file to discover all available pages before exploring further.

# WireMock HTTPS and mutual TLS (mTLS)

> Call WireMock Cloud mock APIs over HTTPS, serve local mocks with your own TLS certificate, and record from APIs that require mTLS client certificates.

Mock APIs in WireMock Cloud work over HTTPS with no setup, but they can't require a client certificate, so they can't
test mutual TLS (mTLS). To record from an API that requires mTLS, use the WireMock CLI with your client certificate.

## HTTPS on WireMock Cloud mock APIs

Every mock API hosted in WireMock Cloud can be called over both HTTPS and HTTP at its base URL, for example
`https://my-mock-api.wiremockapi.cloud`. There is no certificate to configure.

## Mutual TLS on mock APIs

Mock APIs don't request a client certificate from callers, so they can't verify mutual TLS, whether hosted in WireMock
Cloud or run locally with the CLI or Runner.
To control who can call a hosted mock API, use HTTP Basic, header match or OpenID Connect authentication instead - see
[Mock API security](https://docs.wiremock.io/security/security.md#mock-api-security).

If your test needs the mock to require a client certificate, run [WireMock OSS](https://wiremock.org/docs/https/) with
client certificate verification enabled.

## Serving local mock APIs over HTTPS

When you run mock APIs locally with the [WireMock CLI](https://docs.wiremock.io/cli/local-playback.md) or in your own infrastructure with the
[WireMock Runner](https://docs.wiremock.io/runner/serve.md), you can serve them over HTTPS with your own certificate.
Add an `https` section to the service in `.wiremock/wiremock.yaml`:

```yaml theme={null}
services:
  my-service:
    type: REST
    name: "Secure API"
    https:
      port: 8443
      certificate:
        pem: /path/to/certificate.pem
```

The certificate can be a PEM file containing the private key and X509 certificate, or a PKCS12 or JKS keystore.
You can also set one certificate for all services under `global.https`. If no certificate is configured, WireMock's
default self-signed certificate is used.
See [TLS/HTTPS configuration](https://docs.wiremock.io/cli/wiremock-yaml-reference.md#tlshttps-configuration) for every option.

## Recording from an API that requires mutual TLS

Recording in WireMock Cloud can't present a client certificate, so to record from an API that requires mutual TLS, use
the WireMock CLI. Pass a PEM file containing the private key and X509 certificate:

```shell theme={null}
wiremock record https://mutual-tls-endpoint --to=cloud:<mock-api-id> \
  --client-certificate=/path/to/file.pem
```

Or pass a password-protected PKCS12 keystore:

```shell theme={null}
wiremock record https://mutual-tls-endpoint --to=cloud:<mock-api-id> \
  --client-certificate-store=/path/to/file.pkcs12
```

The same options work with `wiremock record-many`. See [Recording via the CLI](https://docs.wiremock.io/cli/recording.md) and
[Multi-domain recording](https://docs.wiremock.io/cli/multi-domain-recording.md) for details.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.