如何编辑使用openssl xampp创建的自签名证书?

如何编辑使用openssl xampp创建的自签名证书?,openssl,xampp,ssl-certificate,self-signed,Openssl,Xampp,Ssl Certificate,Self Signed,我使用内置于xampp中的openssl创建了自己的自签名证书。但是,我想编辑公共名称,这可能吗?有人知道如何覆盖证书吗 但是,我想编辑公共名称,这可能吗?有人知道如何覆盖证书吗 这本身是不可能的。公共名称(CN)位于已签名的证书部分,因此您不能简单地删除它而不使签名无效 但是,您可以简单地生成一个新的证书请求或自签名证书,其中DNS名称在使用者备用名称(SAN)中(而不是在通用名称(CN)中) 在SAN中使用DNS名称创建自签名证书的诀窍是,您需要使用自定义配置文件。您不能仅使用命令行生成一个

我使用内置于xampp中的openssl创建了自己的自签名证书。但是,我想编辑公共名称,这可能吗?有人知道如何覆盖证书吗

但是,我想编辑公共名称,这可能吗?有人知道如何覆盖证书吗

这本身是不可能的。公共名称(CN)位于已签名的证书部分,因此您不能简单地删除它而不使签名无效

但是,您可以简单地生成一个新的证书请求或自签名证书,其中DNS名称在使用者备用名称(SAN)中(而不是在通用名称(CN)中)

在SAN中使用DNS名称创建自签名证书的诀窍是,您需要使用自定义配置文件。您不能仅使用命令行生成一个,因为SAN中的DNS名称未被复制。下面是我使用的自定义CONF文件(名为
example com.CONF


示例com.conf

# 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        = test@example.com

# Section x509_ext is used when generating a self-signed certificate. I.e., openssl req -x509 ...
[ 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

抱歉,我的意思是“编辑”/“更改证书的通用名称”。不能创建一个新的来覆盖现有的吗?我想知道重新安装xampp然后再次创建证书是否会更容易?@fondillusions-是的,您可以覆盖现有证书。只需确保更改XAMPP配置文件中的证书和私钥即可。没有必要重新安装XAMPP。这就像买一辆新车需要换油一样。太好了,谢谢!如何更改XAMPP配置文件中的证书和私钥?对不起,有点新手。我将再次按照相同的步骤创建自签名证书。。(肯定是不对的?)我得到了一个错误-系统库:fopen:Unknown error…@fondillusions-请参阅,以及其他相关问题。