我在网上阅读的所有文章都谈到了为您拥有的域创建自签名证书。
我在家中的Ubuntu 16.04服务器上设置了Apache2。我的ISP为我提供了动态IP,因此我使用No-IP。我在路由器上打开了端口,以将流量重定向到服务器。
我还可以在家中(网络内部)访问Web服务器。
因此,如果我不在家庭网络中,则将使用https://username.noip.me/;如果我在家中,则将使用https:// homeserver /。
那么,如何针对这种情况创建自签名证书?我把什么叫通用名?
我把什么叫通用名?
出于两个原因,您将通俗名称(CN)用作友好名称。首先,它是通过工具显示给用户的,因此您需要诸如Example Widgets,LLC之类的东西。其次,主机名始终位于主题备用名称(SAN)中。IETF和CA / B论坛均不建议在CN中放置主机名。
有关更多规则和原因,请参阅如何与证书颁发机构签署证书签名请求和如何使用openssl创建自签名证书?
那么,如何针对这种情况创建自签名证书?
将该openssl
实用程序与自定义配置文件一起使用。下面是一个示例。
你应该做两件事。首先,将DNS名称列表更改为username.noip.me
和homeserver
。其次,在更改证书中所需的名称后,运行以下命令:
openssl req -config example-com.conf -new -x509 -sha256 -newkey rsa:2048 -nodes \
-keyout example-com.key.pem -days 365 -out example-com.cert.pem
显然,您可以将配置文件的名称从example-com.conf
更改为所需的任何名称。
另外,在家里,我运行自己的PKI。我有一个根CA,可以在需要时为我的网络上的设备颁发证书。所有设备都安装了根CA。我的内部域名称为home.pvt
。网络上的主机被命名为,pine64.home.pvt
,rpi3.home.pvt
,solaris.home.pvt
,windows10.home.pvt
,等一切正常。
示例配置文件
# Self Signed (note the addition of -x509):
# openssl req -config example-com.conf -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout example-com.key.pem -days 365 -out example-com.cert.pem
# Signing Request (note the lack of -x509):
# openssl req -config example-com.conf -new -newkey rsa:2048 -nodes -keyout example-com.key.pem -days 365 -out example-com.req.pem
# Print it:
# openssl x509 -in example-com.cert.pem -text -noout
# openssl req -in example-com.req.pem -text -noout
[ req ]
default_bits = 2048
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
# The Subject DN can be formed using X501 or RFC 4514 (see RFC 4519 for a description).
# Its sort of a mashup. For example, RFC 4514 does not provide emailAddress.
[ subject ]
countryName = Country Name (2 letter code)
countryName_default = US
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = NY
localityName = Locality Name (eg, city)
localityName_default = New York
organizationName = Organization Name (eg, company)
organizationName_default = Example, LLC
# Use a friendly name here because its presented to the user. The server's DNS
# names are placed in Subject Alternate Names. Plus, DNS names here is deprecated
# by both IETF and CA/Browser Forums. If you place a DNS name here, then you
# must include the DNS name in the SAN too (otherwise, Chrome and others that
# strictly follow the CA/Browser Baseline Requirements will fail).
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = Example Company
emailAddress = Email Address
emailAddress_default = [email protected]
# Section x509_ext is used when generating a self-signed certificate. I.e., openssl req -x509 ...
# If RSA Key Transport bothers you, then remove keyEncipherment. TLS 1.3 is removing RSA
# Key Transport in favor of exchanges with Forward Secrecy, like DHE and ECDHE.
[ x509_ext ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
# RFC 5280, Section 4.2.1.12 makes EKU optional
# CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused
# extendedKeyUsage = serverAuth, clientAuth
# Section req_ext is used when generating a certificate signing request. I.e., openssl req ...
[ req_ext ]
subjectKeyIdentifier = hash
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
# RFC 5280, Section 4.2.1.12 makes EKU optional
# CA/Browser Baseline Requirements, Appendix (B)(3)(G) makes me confused
# extendedKeyUsage = serverAuth, clientAuth
[ alternate_names ]
DNS.1 = example.com
DNS.2 = www.example.com
DNS.3 = mail.example.com
DNS.4 = ftp.example.com
# Add these if you need them. But usually you don't want them or
# need them in production. You may need them for development.
# DNS.5 = localhost
# DNS.6 = localhost.localdomain
# DNS.7 = 127.0.0.1
# IPv6 localhost
# DNS.8 = ::1
# DNS.9 = fe80::1
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句