使用OpenSSL为本地主机创建CSR

4
我正在使用openssl(在Windows上)创建csr以配合(测试试用)证书。我之前从未这样做过,我有一个问题: 在创建私钥后,您需要创建一个csr文件,并要求输入个人信息。其中之一是Common Name,即域名。目前我只在本地主机上运行。我正在练习如何创建https://网站。
问题:我是否可以通过像localhost:82这样的方式创建有效的csr?如果不行,我应该怎么做?
1个回答

5
简单回答:打开你的hosts文件(C:\Windows\System32\drivers\etc\hosts),并想出一个漂亮的域名:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#       ::1             localhost
127.0.0.1       localhost

127.0.0.1       example.com  # <<< Your fancy domain goes here !!!

接下来,告诉你的网络服务器将HTTPS请求服务于example.com


不,你可以随意命名(例如,google.com 也可以)。 hosts 文件优先于 DNS 查找,因此基本上可以选择任何您喜欢的名称。回答您的另一个问题:您不需要在 CSR 中指定特定端口,通用名称基本上是您的域或子域(如果您想保护 www.example.com)。 - aefxx
好的,谢谢。我想现在我只会使用本地主机,因为从你所说的来看,它和example.com一样好。无论如何,一旦我将其发布,我将生成新的密钥和csr。 - user1015214

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接