httpApiSimulation("tls-pem-cert-n-key-simulation",
usingApiSimulator()
.with(TlsPemCertificate.certificate(
"classpath:test_certificate.pem", "classpath:test_private_key.pem")
) // these can be absolute paths, too
.instance()
);
Simulations over HTTPS
Overview
Many APIs require HTTPS connections. Here is how to configure TLS in an Embedded API Simulator for simulations over HTTPS using one of the three supported configuration methods.
Cert and Key in PEM format
This is how to configure Embedded API Simulator with X.509 certificate and private key in PEM format for TLS connections:
Passphrase-protected and encrypted private keys are currently not supported. Here is an example how to decrypt a private key in PKCS8 format using openssl
(you’ll be asked to provide the passphrase):
openssl pkcs8 -in my_private_key.key -out my_private_key.pem
Cert Generated at Run-time
At run-time an Embedded API Simulator can generate and use self-signed certificate. You just have to specify the domain for which the certificate is to be:
httpApiSimulation("tls-self-signed-cert-simulation",
usingApiSimulator()
.with(TlsSelfSignedCertificate.certificate("apisimulation.com"))
.instance()
);
If a fully qualified domain name is not specified then the cert is issued for localhost
.
Java KeyStore (JKS)
httpApiSimulation("tls-keystore-simulation",
usingApiSimulator()
.with(TlsKeyStore.keyStore("classpath:apisimulator.jks") // can be absolute path, too
.withStorePassword("storepass") // configure only if needed
.withKeyPassword("keypass") // configure only if needed
)
.instance()
);
We would love to hear your feedback - send us a quick email to [feedback at APISimulator.com]
Happy API Simulating!