Search code examples
sslssl-certificatetls1.2keytoolself-signed-certificate

Testing TLS in localhost: Certificate is invalid for given domain


I am trying to test SSL with a spring boot app running on my personal computer. I generated a PKCS12 certificate using keytool with the following parameters.

CN = localhost:8080
OU = localhost:8080
O = localhost:8080
L = Galle
S = Galle
C = LK

I configured my app to use this certificate and installed this self signed certificate in to my chrome browser.

enter image description here

When I attempt to access my API endpoint (https://localhost:8080/api/meta/divisions) using the chrome extension Advanced REST client, I am receiving an error saying

Certificate is invalid for given domain
Certificate presented to the app has different CN (common name) than the domain of the request.

What is the reason for this error, how can I fox this?


Solution

  • This was fixed when using 127.0.0.1 as CN and filling a SAN extension when generating the self signed certificate.