apache 如何使用 SSL 创建用于本地开发的证书?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1203815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a certificate for local development with SSL?
提问by oym
I am currently doing local development on a webproject using a LAMP stack. Since my production application will be using https for login, I'd like to be able to mimic this in my local dev environment so that all the url's remain consistent. I am new to ssl certificates so could anyone please point me to some reference on how to do this? Would I need to sign my own certificate? Where do I put the certificate (I have virtualhost configurations using apache)? Thanks.
我目前正在使用 LAMP 堆栈对 web 项目进行本地开发。由于我的生产应用程序将使用 https 进行登录,我希望能够在我的本地开发环境中模拟这一点,以便所有 url 保持一致。我是 ssl 证书的新手,所以有人可以指点我一些关于如何做到这一点的参考吗?我需要签署自己的证书吗?我把证书放在哪里(我有使用 apache 的虚拟主机配置)?谢谢。
回答by bschuster
I'm new here but go to this site and the information there
我是新来的,但去这个网站和那里的信息
回答by duffymo
You can use Java's keystoreto generate a self-signed certificate for local development.
您可以使用Java 的密钥库生成本地开发的自签名证书。
回答by Wil
You are best off making a self signed certificate and adding it to whatever machine you use for testing. It should then appear "real" to the client... of course, it is real... just not by a "trusted" place. (quote marks because I swear it is all about money!)
您最好制作一个自签名证书并将其添加到您用于测试的任何机器上。然后它应该对客户来说是“真实的”……当然,它是真实的……只是不是在“受信任”的地方。(引号是因为我发誓这完全是为了钱!)
I just found this page that should step you through it
我刚刚找到这个页面,应该引导你完成它
回答by lumpynose
My favorite is Ralf's documentation for apache modssl. This page explains how to make a test cert. It's the one I always go to when I need to make one.
我最喜欢的是 Ralf 的 apache modssl 文档。本页介绍了如何制作测试证书。当我需要制作一个时,这是我总是去的那个。
回答by Dave Anderson
Obviously since you're using Java and Apache this isn't going to be much good but anyhow, if you also do any .Net development you'll have these tools available and maybe this can help you on your way and actually generate the certificate. I use makecertwhich is available in the .Net SDK, here's the batch file I use for creating my own SSL certificates for local .Net development and IIS;
显然,由于您使用的是 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
Change the "CN=localhost"if you use another host header to acces the site, you'll maybe need to change the path in the CALLstatement depending on which version of Visual Studio you have.
更改"CN=localhost"如果您使用另一个主机头访问站点,您可能需要CALL根据您拥有的 Visual Studio 版本更改语句中的路径。

