我目前正在使用 LAMP 堆栈对 web 项目进行本地开发。由于我的生产应用程序将使用 https 进行登录,我希望能够在我的本地开发环境中模仿这一点,以便所有 url 保持一致。我是 ssl 证书的新手,所以有人可以指点我一些关于如何做到这一点的参考吗?我需要签署自己的证书吗?我在哪里放置证书(我有使用 apache 的虚拟主机配置)?谢谢。
6 回答
我是新来的,但是去这个网站和那里的信息
您可以使用Java 的密钥库为本地开发生成自签名证书。
您最好制作一个自签名证书并将其添加到您用于测试的任何机器上。然后它应该对客户来说是“真实的”......当然,它是真实的......只是不是在“受信任”的地方。(引号,因为我发誓这一切都是为了钱!)
我刚刚发现这个页面应该可以引导你完成它
我认为 2020 年要走的路可能是使用一些命令行工具,例如
mkcert
https://github.com/FiloSottile/mkcertminica
https://github.com/jsha/minicaFishdrowned/ssl
https://github.com/Fishdrown/ssldevilbox/cert-gen
https://github.com/devilbox/cert-gen
All the tools are wrappers arround some openssl command or other lib to generate certificates.
我最喜欢的是 Ralf 的 apache modssl 文档。本页介绍如何制作测试证书。当我需要制作一个时,我总是会去那个。
显然,因为您使用的是 Java 和 Apache,所以这不会很好,但无论如何,如果您还进行任何 .Net 开发,您将拥有这些工具,也许这可以帮助您并实际生成证书. 我使用makecert
的是 .Net SDK 中提供的,这是我用于为本地 .Net 开发和 IIS 创建自己的 SSL 证书的批处理文件;
@ECHO OFF
REM
REM This script will create a certificate to enable HTTPS for the localhost in IIS
REM Complete the following steps to install the certificate
REM
REM 1. Run this file to create the certificate
REM 2. Open MMC.exe
REM 3. Click File > Add/Remove Snap In > Add and select 'Certificates'
REM 4. Select 'Computer Account'
REM 5. Select 'Local Computer' and click 'Finish', 'Close', 'OK'
REM 6. Expand Certificates > Personal > Certificates, the new certificate should be listed
REM 7. In IIS open the Properties of the Default Web Site
REM 8. Select 'Directory Security' tab and click 'Server Certificate'
REM 9. The Certificate Wizard will open, choose 'Assign Existing Certificate' [may need to cancel a pending certificate request]
REM 10. Select new certificate from list and accept change
REM 11. Ensure that the site is using the default port for SSL 443
REM
C:
CD \
CALL "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sdkvars.bat"
ECHO Creating Certificate
makecert -r -pe -n "CN=localhost" -b 01/01/2000 -e 01/01/2036 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
PAUSE
更改"CN=localhost"
如果您使用另一个主机标头来访问该站点,您可能需要CALL
根据您拥有的 Visual Studio 版本更改语句中的路径。