带有OpenSSL的自签名证书,适用于家庭服务器,无域名

IMTheNachoMan

我在网上阅读的所有文章都谈到了为您拥有的域创建自签名证书。

我在家中的Ubuntu 16.04服务器上设置了Apache2。我的ISP为我提供了动态IP,因此我使用No-IP。我在路由器上打开了端口,以将流量重定向到服务器。

我还可以在家中(网络内部)访问Web服务器。

因此,如果我不在家庭网络中,则将使用https://username.noip.me/;如果我在家中,则将使用https:// homeserver /

那么,如何针对这种情况创建自签名证书?我把什么叫通用名?

w

我把什么叫通用名?

出于两个原因,您将通俗名称(CN)用作友好名称首先,它是通过工具显示给用户的,因此您需要诸如Example Widgets,LLC之类的东西其次,主机名始终位于主题备用名称(SAN)中IETF和CA / B论坛均不建议在CN中放置主机名。

有关更多规则和原因,请参阅如何与证书颁发机构签署证书签名请求如何使用openssl创建自签名证书?


那么,如何针对这种情况创建自签名证书?

将该openssl实用程序与自定义配置文件一起使用。下面是一个示例。

你应该做两件事。首先,将DNS名称列表更改为username.noip.mehomeserver其次,在更改证书中所需的名称后,运行以下命令:

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.pvtrpi3.home.pvtsolaris.home.pvtwindows10.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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

即插即用,适用于带有和不带有DHCP服务器的网络

来自分类Dev

无服务器示例不适用于无服务器本地堆栈插件

来自分类Dev

带有Backbone.js路由器的HTML5 pushState不适用于特定服务器,但适用于其他服务器

来自分类Dev

Perl Search :: Elasticsearch不适用于具有自签名证书的启用SSL的节点

来自分类Dev

适用于特定服务器的http.sslCAInfo证书正确的.gitconfig语法是什么?

来自分类Dev

带有附件的电子邮件适用于gmail,但不适用于Outlook或我的邮件服务器

来自分类Dev

适用于无服务器的AWS CodePipeline:与Gitlab集成

来自分类Dev

如何使用适用于AWS Lambda的无服务器框架获取最新的Layer版本

来自分类Dev

psycopg2不适用于AWS Lambda上的无服务器框架部署

来自分类Dev

适用于AWS Code Pipleline中无服务器框架的Buildspec.yaml

来自分类Dev

无密码ssh不适用于多台服务器

来自分类Dev

适用于Android的带有Delphi XE5的多线程服务器套接字

来自分类Dev

从服务器获取或卷曲自签名证书

来自分类Dev

Postfix TLS的自签名服务器证书

来自分类Dev

服务器上的自签名证书列表

来自分类Dev

websocket服务器的自签名证书的“通用名称无效”

来自分类Dev

Electron 内部节点 Web 服务器的自签名证书

来自分类Dev

AWS ELB->具有自签名证书的HTTPS后端服务器

来自分类Dev

具有自签名证书的 TLS 安全 TCP 服务器和客户端

来自分类Dev

是否有适用于 Windows 10 iot 的服务 DHCP 服务器?

来自分类Dev

适用于服务器的Apple Push Notifications服务

来自分类Dev

带有 dnsmasq 的家庭服务器 DNS

来自分类Dev

适用于AWS的无服务器框架:将初始数据添加到Dynamodb表中

来自分类Dev

适用于Linux的Bare bones HTTP服务器,具有可恢复的文件下载

来自分类Dev

腻子没有任何颜色,仅适用于一台服务器

来自分类Dev

CSS不再适用于其他服务器

来自分类Dev

SetState不适用于服务器中的数据

来自分类Dev

适用于服务器的Ubuntu vs Debian

来自分类Dev

jQuery似乎不适用于服务器控制

Related 相关文章

  1. 1

    即插即用,适用于带有和不带有DHCP服务器的网络

  2. 2

    无服务器示例不适用于无服务器本地堆栈插件

  3. 3

    带有Backbone.js路由器的HTML5 pushState不适用于特定服务器,但适用于其他服务器

  4. 4

    Perl Search :: Elasticsearch不适用于具有自签名证书的启用SSL的节点

  5. 5

    适用于特定服务器的http.sslCAInfo证书正确的.gitconfig语法是什么?

  6. 6

    带有附件的电子邮件适用于gmail,但不适用于Outlook或我的邮件服务器

  7. 7

    适用于无服务器的AWS CodePipeline:与Gitlab集成

  8. 8

    如何使用适用于AWS Lambda的无服务器框架获取最新的Layer版本

  9. 9

    psycopg2不适用于AWS Lambda上的无服务器框架部署

  10. 10

    适用于AWS Code Pipleline中无服务器框架的Buildspec.yaml

  11. 11

    无密码ssh不适用于多台服务器

  12. 12

    适用于Android的带有Delphi XE5的多线程服务器套接字

  13. 13

    从服务器获取或卷曲自签名证书

  14. 14

    Postfix TLS的自签名服务器证书

  15. 15

    服务器上的自签名证书列表

  16. 16

    websocket服务器的自签名证书的“通用名称无效”

  17. 17

    Electron 内部节点 Web 服务器的自签名证书

  18. 18

    AWS ELB->具有自签名证书的HTTPS后端服务器

  19. 19

    具有自签名证书的 TLS 安全 TCP 服务器和客户端

  20. 20

    是否有适用于 Windows 10 iot 的服务 DHCP 服务器?

  21. 21

    适用于服务器的Apple Push Notifications服务

  22. 22

    带有 dnsmasq 的家庭服务器 DNS

  23. 23

    适用于AWS的无服务器框架:将初始数据添加到Dynamodb表中

  24. 24

    适用于Linux的Bare bones HTTP服务器,具有可恢复的文件下载

  25. 25

    腻子没有任何颜色,仅适用于一台服务器

  26. 26

    CSS不再适用于其他服务器

  27. 27

    SetState不适用于服务器中的数据

  28. 28

    适用于服务器的Ubuntu vs Debian

  29. 29

    jQuery似乎不适用于服务器控制

热门标签

归档