Non-wildcard certificates with dynamic apache vhosts

こ雲淡風輕ζ 提交于 2019-12-24 00:37:29

问题


I'm trying to dynamically read the location of the SSL certificates depending on which url was used to connect to my server. I have attempted a few different ways but none seem to work. Currently I have the config as noted below

UseCanonicalName Off

listen 443

<VirtualHost *:443>
  ServerName example
  ServerAlias *

  SSLEngine on
  SSLCertificateFile /etc/letsencrypt/live/%0/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/%0/privkey.pem

  VirtualDocumentRoot /var/www/vhosts/%-2/%-3+/public
</VirtualHost>

The problem here is that when I start apache I get an error saying it can't find the file location for the ssl certificate stating '/etc/letsencrypt/live/%0/cert.pem'

So it seems the %0 is not being replaced by the url.

Edit: When I replace only %0 by the url manually then said url has working SSL


回答1:


From the documentation:

The variable %0 references the requested servername, as indicated in the Host: header.

The Host header is part of the HTTP request. The HTTP request is only available after the successful TLS handshake. The certificate is needed for this handshake. Thus, %0 can not be used to specify the path to the certificate.

I doubt that any other variables will be possible for this purpose since the certificates are loaded at startup and thus the file names have to be available already at start.



来源:https://stackoverflow.com/questions/41635535/non-wildcard-certificates-with-dynamic-apache-vhosts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!