美文网首页
自签证书使用https

自签证书使用https

作者: 蜗牛_3c49 | 来源:发表于2020-01-14 11:06 被阅读0次

openssl req -new -x509 -newkey rsa:4096 -keyout client.key -out client.crt -config openssl.cnf -days 365

ps:当前文件夹下必须得有openssl.cnf配置文件,直接copy系统默认的配置文件过来就好.是openssl相关的

    另外,末尾的-days 365 表示该证书有效期为365天

添加一些配置到openssl.cnf这个文件:

[ req ]

x509_extensions = v3_req

[v3_req]

subjectAltName          = @subjectAltNames

[subjectAltNames]

DNS.1 = winbet888.net

DNS.2 = www.winbet888.net

#IP.1 = 127.0.0.1

ps: subjectAltNames下可以添加键值对,域名用dns,ip用IP

终端会提示设置一些东西,其他都可以不填

Common Name (eg, fully qualified host name) []:

Email Address []:

这两个必填,可以随意填

PS:subjectAltNames设置是关键,键值对直接决定了浏览器验证你的证书信息和域名和访问的位置是否能对上!!

最后生成一个crt文件和key文件,客户端安装crt就行了.服务器两个都用.

服务器部署的时候,会提示无法找到私钥,执行以下命令,

openssl rsa -in client.key -out client.key

拿着新的client.key去替换之前的

如果安装的openssl没有默认的配置文件,那么可以使用以下这个(只在windows系统上的openssl测试可行):

==================

################################################################

# openssl example configuration file.

# This is mostly used for generation of certificate requests.

#################################################################

[ ca ]

default_ca= CA_default # The default ca section

#################################################################

[ CA_default ]

dir=C:/Program Files/Apache Group/Apache2/conf/ssl # Where everything is kept

certs=$dir # Where the issued certs are kept

crl_dir= $dir/crl # Where the issued crl are kept

database= $dir/index.txt # database index file

new_certs_dir= $dir/new_certs # default place for new certs

certificate=$dir/CA/OrbixCA # The CA certificate

serial= $dir/serial # The current serial number

crl= $dir/crl.pem # The current CRL

private_key= $dir/CA/OrbixCA.pk # The private key

RANDFILE= $dir/.rand # private random number file

default_days= 365 # how long to certify for

default_crl_days= 30 # how long before next CRL

default_md= md5 # which message digest to use

preserve= no # keep passed DN ordering

# A few different ways of specifying how closely the request should

# conform to the details of the CA

policy= policy_match

# For the CA policy [policy_match]

countryName= match

stateOrProvinceName= match

organizationName= match

organizationalUnitName= optional

commonName= supplied

emailAddress= optional

# For the `anything' policy

# At this point in time, you must list all acceptable `object'

# types

[ policy_anything ]

countryName = optional

stateOrProvinceName= optional

localityName= optional

organizationName = optional

organizationalUnitName = optional

commonName= supplied

emailAddress= optional

[ req ]

default_bits = 1024

default_keyfile= privkey.pem

distinguished_name = req_distinguished_name

attributes = req_attributes

[ req_distinguished_name ]

countryName= Country Name (2 letter code)

countryName_min= 2

countryName_max = 2

stateOrProvinceName= State or Province Name (full name)

localityName = Locality Name (eg, city)

organizationName = Organization Name (eg, company)

organizationalUnitName = Organizational Unit Name (eg, section)

commonName = Common Name (eg. YOUR name)

commonName_max = 64

emailAddress = Email Address

emailAddress_max = 40

[ req_attributes ]

challengePassword = A challenge password

challengePassword_min = 4

challengePassword_max = 20

unstructuredName= An optional company name

ps:注意,以上配置可以根据需要修改.

或者下面这一段也行:

[ req ]

#default_bits = 2048

#default_md = sha256

#default_keyfile = privkey.pem

distinguished_name = req_distinguished_name

attributes = req_attributes

x509_extensions = v3_req

[v3_req]

subjectAltName = @subjectAltNames

[ req_distinguished_name ]

countryName = Country Name (2 letter code)

countryName_min = 2

countryName_max = 2

stateOrProvinceName = State or Province Name (full name)

localityName = Locality Name (eg, city)

0.organizationName = Organization Name (eg, company)

organizationalUnitName = Organizational Unit Name (eg, section)

commonName = Common Name (eg, fully qualified host name)

commonName_max = 64

emailAddress = Email Address

emailAddress_max = 64

[ req_attributes ]

challengePassword = A challenge password

challengePassword_min = 4

challengePassword_max = 20

[subjectAltNames]

IP.1 = 127.0.0.1

ps:注意,以上配置根据需要修改.

相关文章

  • 申请https证书自签

    Https证书一直以来都是在阿里下载的免费版,每年更新一次。其实我们可以使用certbot来自动完成。 可以支持大...

  • 生成自签https证书

    首先说明一下,自己的生成的CA证书并不是权威机构的CA,在Chrome会被识别成不安全的网站,这里只做流程演示。本...

  • nginx使用自签CA证书(https访问)

    @[toc] 前言以容器为例,说明nginx自签CA证书的使用。目录结构如下: 1. nginx.conf htt...

  • Https自定义证书引入问题(2)

    上一篇介绍接口使用https并且证书是自签的情况下,如何在客户端信任服务器证书,没有看过的请移步 Https自定义...

  • 使用自签搭建https

    作为笔记。。。以后有时间再整理把。。。httpd-2.2实现 Centos 6自带的base仓库里的httpd默认...

  • 自签证书使用https

    openssl req -new -x509 -newkey rsa:4096 -keyout client.ke...

  • apache-tomcat-9.0.35 配置https

    1、生成自签https证书 2、配置tomcat https 1、修改server.xml配置到tomcat->c...

  • iOS企业签名App

    苹果企业证书签名(企业签) 公司之前账号被封,所以用了企业签。记录一下。推荐使用iResign[https://g...

  • nginx配置https

    1 使用openssl生成证书 这里我们使用openssl进行CA证书自签,用来学习,有条件的可以让第三方机构进行...

  • unity ssl自签证书

    开发了一个国企的app,整个是一个只有内网的项目,使用了自签的ssl证书,所以需要使用其自签证书。 在unity里...

网友评论

      本文标题:自签证书使用https

      本文链接:https://www.haomeiwen.com/subject/ufwoactx.html