Aurea Li
08/15/2024, 11:17 PMWireMock uses a root Certificate Authority private key to sign a certificate for each host that it proxies. By default, WireMock will use a CA key store atI'm using cert-manager and kubernetes to generate my own certificate that I want to pass down to Wiremock. When I pipe in the certificate I generated like so. If this key store does not exist, WireMock will generate it with a new secure private key which should be entirely private to the system on which WireMock is running. You can provide a key store containing such a private key & certificate yourself using the$HOME/.wiremock/ca-keystore.jks
,--ca-keystore
&--ca-keystore-password
options.--ca-keystore-type
--ca-keystore=/etc/wiremock-certificate/keystore.jks
but when I try to make a call that gets proxied through Wiremock, it presents me with the default certificate instead of the one I specified through the options. See 🧵Aurea Li
08/15/2024, 11:19 PMaurea ~/Development/persona-kubernetes [aurea/PER-29086/wiremock-cert-manager] $ k exec -it wiremock-6c987c9d64-g8jpl -n wiremock -- keytool -list -v -keystore /etc/wiremock-certificate/keystore.jks
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 2 entries
Alias name: ca
Creation date: Aug 15, 2024
Entry type: trustedCertEntry
Owner: CN=Wiremock Root CA
Issuer: CN=Wiremock Root CA
etc...
yet the certificate I receive back is
root@shell-demo:/# openssl s_client -connect <http://example.org:443|example.org:443> -showcerts
CONNECTED(00000003)
depth=0 C = Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = Tom Akehurst
verify error:num=18:self-signed certificate
verify return:1
depth=0 C = Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = Tom Akehurst
verify return:1
---
Certificate chain
0 s:C = Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = Tom Akehurst
i:C = Unknown, ST = Unknown, L = Unknown, O = Unknown, OU = Unknown, CN = Tom Akehurst
Aurea Li
08/15/2024, 11:19 PMAurea Li
08/15/2024, 11:19 PMAurea Li
08/15/2024, 11:21 PM--https-port=8443,--port=9021,--max-request-journal=1000,--local-response-templating,--root-dir=/home/wiremock/storage,--enable-browser-proxying,--ca-keystore=/etc/wiremock-certificate/keystore.jks
Aurea Li
08/15/2024, 11:24 PM<http://example.org|example.org>
to the Wiremock service I'm running.Aurea Li
08/15/2024, 11:25 PMroot@shell-demo:/# curl <https://example.org> -k
Wiremock stub.root@shell-demo:/#
{
"uuid": "5f4266b1-7138-4d60-9d55-e72ea0ba5ff2",
"request": {
"url": "/",
"method": "GET"
},
"response": {
"status": 200,
"body": "Wiremock stub.",
"headers": {
"Content-Type": "text/plain"
}
}
}
Aurea Li
08/16/2024, 7:37 PMAurea Li
08/16/2024, 9:35 PM--ca-keystore=
option works at all. I am using the wiremock/wiremock:3.8.0
image. I can use --https-keystore
option but I have to pass in a cert with the matching hostname I want to stub. I can't do it for multiple calls to different hostnames.