成都网站开发公司排名,青海省建设厅官方网站建设云,成都网站建设哪家售后好,新媒体营销方案策划书1、openssl生成CA根证书 1.1、生成CA私钥 openssl genrsa -out root_ca.key 2048 注意#xff1a;私钥必须妥善保管#xff0c;既不能丢失#xff0c;也不能泄露。如果发生丢失和泄露#xff0c;必须马上重新 生成#xff0c;以使旧的证书失效。 1.2、通过ca私钥生成pem格…
1、openssl生成CA根证书 1.1、生成CA私钥 openssl genrsa -out root_ca.key 2048 注意私钥必须妥善保管既不能丢失也不能泄露。如果发生丢失和泄露必须马上重新 生成以使旧的证书失效。 1.2、通过ca私钥生成pem格式的ca根证书 openssl req -x509 -new -nodes -key root_ca.key -sha256 -days 36500 -out root_ca.pem 接下来需要填写 Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:ShannXi Locality Name (eg, city) [Default City]:XiAn Organization Name (eg, company) [Default Company Ltd]:xxx Organizational Unit Name (eg, section) []:Test Common Name (eg, your name or your servers hostname) []:xxx Email Address []: 注意‘-days 36500’代表生成的根证书的有效期为36500天下面的参数根据实际填写即可。
2、用根证书签发server证书 2.1、生成服务端私钥 openssl genrsa -out http_server.key 2048 2.2、新建server_req.conf文件 [req] default_bits 2048 distinguished_name req_distinguished_name req_extensions req_ext x509_extensions v3_req prompt no [req_distinguished_name] countryName CN stateOrProvinceName ShannXi localityName XiAn organizationName xxx commonName *.xxx.com #修改 设备连接用的域名或ip [req_ext] subjectAltName alt_names [v3_req] subjectAltName alt_names [alt_names] IP.1 0.0.0.0 IP.2 127.0.0.1 IP.3 xxxxx IP.4 xxxxx DNS.1 *.xxx.com DNS.2 localhost 注意 1、alt_names里的IP列填设备要访问的服务端的IP地址。 2、alt_names里的DNS列填设备要访问的服务端的域名地址。 3、commonName 填设备要访问的服务端的IP或域名地址。 4、当客户端访问服务端的地址为IP地址那么只会在x509的扩展项subjectAltName中寻找IP进行 匹配也就是到alt_names里面的IP列去寻找IP进行匹配。 5、当客户端访问服务端的地址为域名地址则除了在 subjectAltName 中寻找域名进行匹配也就是到alt_names里面的DNS列去匹配外还会检查req_distinguished_name中的 commonName 是否和域名匹配。 2.3、生成证书签名请求 openssl req -new -key ./http_server.key -config server_req.conf -out http_server.csr 2.4、生成最终服务端证书 用请求文件、根证书、私钥、server_req.conf签发新的服务端证书http_server.pem 设置有效期为36500天。
openssl x509 -req -in ./http_server.csr -CA root_ca.pem -CAkey root_ca.key -CAcreateserial -out http_server.pem -days 36500 -sha256 -extensions v3_req -extfile server_req.conf
3、用根证给签发client证书 3.1生成客户端私钥 openssl genrsa -out xxxxx.key 2048 注意文件名为xxxxx。 3.2、生成客户端证书签名请
openssl req -new -key xxxxx.key -out xxxxx.csr -subj /CCN/STShanghai/LShanghai/OShanghai/CNxxxxx 注意文件名、参数CN值应该保持一致都为xxxxx。 3.3、签发客户端证书 用证书请求文件、根证书、私钥签发客户端证书xxxxx.pem设置有效期为36500天。文件名为xxxxx。
openssl x509 -req -days 36500 -in xxxxx.csr -CA root_ca.pem -CAkey root_ca.key -CAcreateserial -out xxxxx.pem 4、当更换服务端的IP或者域名时 当迁移服务器导致服务端IP变更或者客户端访问服务端的域名发生变更时我们该如何更换自签名证书 4.1、当服务端的IP发生变更时 只需要将新的IP地址更新到server_req.conf 文件里alt_names 的IP列里面然后用server_req.conf文件重新生成服务端证书签名请求再重新生成服务端证书用新证书替换原有的服务端旧证书再重启ac-gateway-http服务设备端不用变更证书就可以直接访问新服务器了。 4.2、当服务端的域名发生变更时 当服务端是以域名地址提供对外服务时当域名地址变更时我们除了要将新的域名地址更新到server_req.conf 文件里alt_names 的DNS列里面还要将req_distinguished_name中的 commonName值更新成新的域名地址然后用server_req.conf文件重新生成服务端证书签名请求再重新生成服务端证书用新证书替换原有的服务端旧证书然后重启ac-gateway-http服务设备端不用变更证书就可以直接访问新服务器了。