Last step is install client certificate in our device.
In simply way we need pkcs#12 file with client certificate. We copy it to phone and we can instll it during OpenHub configurations.
So as we see it is not only nginx configurations, more works is with certificate management.
Many thanks for this tutorial Slawomir!
Got everything running along with an SSL-Labs A rating of my OpenHAB installation at home.
I think I am finally ready to migrate from Fibaro HC2 to OpenHAB.
Cheers!
How does the Let’s Encrypt certbot renewal work with this? It doesn’t have the client certificate. Do you temporarily disable the client certificate to allow for renewal? Or use some other method?
Also, you also have auth_basic enabled. Why is that? I thought the point of the client certificate validation is that you don’t need it. Or do you want another layer of protection?
The example in the openHAB docs here has a redirect to the https port. Doesn’t that include the certbot domain validation? Wouldn’t that have a problem for the acme challenge? Or do you have the port 80 block configured differently than this example?
server {
listen 80;
server_name mydomain_or_myip;
return 301 https://$server_name$request_uri;
}
According to ACME specification Let’s Encrypt, use port 80 for HTTP-01 challenge.
Probably Let’s Encrypt work ok because follow redirect, so both configuration will be ok.
In this post question was, how to work with Let’s Encrypt and client certificate. So we simply use port 80 for Let’s Encrypt and port 443 for our rest comunication.
Sorry, I misread the original post and somehow thought the acme-challenge was in the original place. I agree that it will work where it is. And I agree that port 80 should be open. But even the page you quoted says all port 80 requests should be redirected to port 443. Anyway, I was thinking that something like this might work in the 443 server. Make the authentication be optional, and check it in the / block. There is no check for the acme-challenge location.
# client certificate
ssl_client_certificate /etc/nginx/client_certs/ca.crt;
ssl_verify_client optional;
location / {
# if the client-side certificate failed to authenticate, show a 403
# message to the client
if ($ssl_client_verify != SUCCESS) {
return 403;
}
Any comments on this? I know “if” has a bad reputation with nginx, but they do seem say this usage type is okay. Maybe this is no better than the original.
Also, I am curious as to why you use basic authentication as well as the client certificate. Just for extra security?
Hello, thank you for the post. I am actually having a blocking problem. I configured my nginx server to use self signed certificates and added the virtual server to handle my clients https requests. However I would like to allow only a list of known clients to call my endpoints. I have the clients certificates and I imported to my Ubuntu. However when I add my client crt certificate to the ssl_client_certificate, restar my nginx and try to access using the pfx Client certificate I am having a 400 bad request. Any idea ? Thank you