mkcert 证书不适用于本地 IP 地址

aki*_*kio 6 linux apache ssl mkcert

我正在尝试将我的应用程序转换为 PWA,我需要在我的 raspberrypi 4 上的本地主机上使用 https,并且可以在 LAN 上使用 192.168.0.2 进行访问

\n

证书似乎无效,我不明白我缺少什么。

\n

所有命令均以root用户执行,所有步骤均来自GitHub官方页面

\n
mkcert -install\n\nmkcert 192.168.80.2\nUsing the local CA at "/root/.local/share/mkcert" \xe2\x9c\xa8\n\nCreated a new certificate valid for the following names \xef\xbf\xbd\n - "192.168.0.2"\n\nThe certificate is at "./192.168.0.2.pem" and the key at "./192.168.0.2-key.pem" \xe2\x9c\x85\n\nmv 192.168.0.2-key.pem /etc/apache2/ssl/192.168.0.2-key.pem\nmv 192.168.0.2.pem /etc/apache2/ssl/192.168.0.2.pem\n\nls -l /etc/apache2/sites-enabled\nlrwxrwxrwx 1 root root   29 Jul 21 16:34 hiker.conf -> ../sites-available/hiker.conf\n
Run Code Online (Sandbox Code Playgroud)\n

可用站点/hiker.conf

\n
<VirtualHost *:80>\n    # The ServerName directive sets the request scheme, hostname and port that\n    # the server uses to identify itself. This is used when creating\n    # redirection URLs. In the context of virtual hosts, the ServerName\n    # specifies what hostname must appear in the request\'s Host: header to\n    # match this virtual host. For the default virtual host (this file) this\n    # value is not decisive as it is used as a last resort host regardless.\n    # However, you must set it for any further virtual host explicitly.\n    ServerName 192.168.0.2\n    ServerAdmin webmaster@localhost\n    DocumentRoot /var/www\n\n    Alias /hiker /var/www/hiker/public\n\n    <Directory /var/www/hiker/public>\n        AllowOverride All\n        Order Allow,Deny\n        Allow from All\n   </Directory>\n\n    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n    # error, crit, alert, emerg.\n    # It is also possible to configure the loglevel for particular\n    # modules, e.g.\n    #LogLevel info ssl:warn\n    ErrorLog ${APACHE_LOG_DIR}/error.log\n    CustomLog ${APACHE_LOG_DIR}/access.log combined\n\n    # For most configuration files from conf-available/, which are\n    # enabled or disabled at a global level, it is possible to\n    # include a line for only one particular virtual host. For example the\n    # following line enables the CGI configuration for this host only\n    # after it has been globally disabled with "a2disconf".\n    #Include conf-available/serve-cgi-bin.conf\n</VirtualHost>\n\n<IfModule mod_ssl.c>\n    <VirtualHost _default_:443>\n        ServerName 192.168.0.2\n        ServerAdmin webmaster@localsite.test\n \n        DocumentRoot /var/www\n \n        Alias /hiker /var/www/hiker/public\n\n        <Directory /var/www/hiker/public>\n            AllowOverride All\n            Order Allow,Deny\n            Allow from All\n        </Directory>\n \n        ErrorLog ${APACHE_LOG_DIR}/localsite-error.log\n        CustomLog ${APACHE_LOG_DIR}/localsite-access.log combined\n \n        SSLEngine on \n        SSLCertificateFile  /etc/apache2/ssl/192.168.0.2.pem\n        SSLCertificateKeyFile /etc/apache2/ssl/192.168.0.2-key.pem\n    </VirtualHost>\n</IfModule>\n\n# vim: syntax=apache ts=4 sw=4 sts=4 sr noet\n\n
Run Code Online (Sandbox Code Playgroud)\n
<VirtualHost *:80>\n    # The ServerName directive sets the request scheme, hostname and port that\n    # the server uses to identify itself. This is used when creating\n    # redirection URLs. In the context of virtual hosts, the ServerName\n    # specifies what hostname must appear in the request\'s Host: header to\n    # match this virtual host. For the default virtual host (this file) this\n    # value is not decisive as it is used as a last resort host regardless.\n    # However, you must set it for any further virtual host explicitly.\n    ServerName 192.168.0.2\n    ServerAdmin webmaster@localhost\n    DocumentRoot /var/www\n\n    Alias /hiker /var/www/hiker/public\n\n    <Directory /var/www/hiker/public>\n        AllowOverride All\n        Order Allow,Deny\n        Allow from All\n   </Directory>\n\n    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n    # error, crit, alert, emerg.\n    # It is also possible to configure the loglevel for particular\n    # modules, e.g.\n    #LogLevel info ssl:warn\n    ErrorLog ${APACHE_LOG_DIR}/error.log\n    CustomLog ${APACHE_LOG_DIR}/access.log combined\n\n    # For most configuration files from conf-available/, which are\n    # enabled or disabled at a global level, it is possible to\n    # include a line for only one particular virtual host. For example the\n    # following line enables the CGI configuration for this host only\n    # after it has been globally disabled with "a2disconf".\n    #Include conf-available/serve-cgi-bin.conf\n</VirtualHost>\n\n<IfModule mod_ssl.c>\n    <VirtualHost _default_:443>\n        ServerName 192.168.0.2\n        ServerAdmin webmaster@localsite.test\n \n        DocumentRoot /var/www\n \n        Alias /hiker /var/www/hiker/public\n\n        <Directory /var/www/hiker/public>\n            AllowOverride All\n            Order Allow,Deny\n            Allow from All\n        </Directory>\n \n        ErrorLog ${APACHE_LOG_DIR}/localsite-error.log\n        CustomLog ${APACHE_LOG_DIR}/localsite-access.log combined\n \n        SSLEngine on \n        SSLCertificateFile  /etc/apache2/ssl/192.168.0.2.pem\n        SSLCertificateKeyFile /etc/apache2/ssl/192.168.0.2-key.pem\n    </VirtualHost>\n</IfModule>\n\n# vim: syntax=apache ts=4 sw=4 sts=4 sr noet\n\n
Run Code Online (Sandbox Code Playgroud)\n
apachectl configtest\nSyntax OK\n
Run Code Online (Sandbox Code Playgroud)\n

镀铬屏幕截图\n在此输入图像描述

\n

aki*_*kio 1

感谢@SteffenUllrich,我找到了解决方案。

我为了将 CA 导入 Windows 10,请按照此处描述的步骤“ make-computer-trust-certificate-authority

我现在可以进行测试以将我的应用程序转换为 PWA