openssl req -x509 -sha256 -days 356 -nodes -newkey rsa:2048 -subj "/CN=msetproot/C=CN/L=GuangDong" -keyout rootCA.key -out rootCA.crt
-subj “/CN=1111/C=CN/L=GuangDong”
1111替换为自定义的机构名称
会出现两个文件
rootCA.key
rootCA.crt CA机构的证书
openssl genrsa -out server.key 20483、创建证书签名请求配置文件
cat > csr.conf <4、使用服务器私钥生成证书签名请求 (CSR) openssl req -new -key server.key -out server.csr -config csr.conf5、使用根证书生成数字证书,先写好配置文件//127.0.0.1修改为 EMQ X 服务器实际的 IP 或 DNS 地址,例如:IP.1 = 127.0.0.1,或
//DNS.1 = broker.xxx.comcat > cert.conf <6、使用自签名 CA 生成 SSL 证书
openssl x509 -req -in server.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out server.crt -days 365 -sha256 -extfile cert.confcert.conf 用来生成根证书(server.crt)的配置
csr.conf 用来生成向CA机构提申请的文件(server.csr)的配置
rootCA.crt 生成的自定义CA机构的拥有的证书
rootCA.key 生成的自定义CA机构的拥有的密钥
rootCA.srl
server.crt 服务器证书
server.csr 证书签名请求 (CSR),包含自己需要申请的服务器证书的配置信息
server.key 服务器私钥,用来生成(server.csr),想CA申请 服务器证书nginx配置示例
server { listen 8088 ssl; #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。 server_name 192.168.6.236; #将localhost修改为您证书绑定的域名,例如:www.example.com。 #root html; #index index.html index.htm; ssl_certificate server.crt; #将domain name.pem替换成您证书的文件名。 ssl_certificate_key server.key; #将domain name.key替换成您证书的密钥文件名。 ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。 ssl_prefer_server_ciphers on; charset utf-8; #access_log logs/host.access.log main; client_max_body_size 1024M; client_body_buffer_size 2M; error_page 497 https://$http_host$request_uri; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; #add_header Content-Security-Policy upgrade-insecure-requests; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; proxy_set_header Connection ""; chunked_transfer_encoding off; proxy_pass http://localhost:8080/; } location ~*/(upload|static|videos)/ { root "D:Msetp-platformwebappsROOT"; index index.html index.htm; expires 1d; } }7、生成tomcat需要的证书
openssl pkcs12 -export -clcerts -in server.crt -inkey server.key -out server.p12 keytool -importkeystore -srckeystore server.p12 -destkeystore server.jks -srcstoretype pkcs12 -deststoretype jks keytool -importkeystore -srckeystore server.jks -destkeystore server.jks -deststoretype pkcs12



