<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SSL &#8211; 良的世界</title>
	<atom:link href="https://www.lemonary.cn/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lemonary.cn</link>
	<description></description>
	<lastBuildDate>Tue, 17 Jun 2025 07:14:06 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.lemonary.cn/wp-content/uploads/2024/12/profile-150x150.jpg</url>
	<title>SSL &#8211; 良的世界</title>
	<link>https://www.lemonary.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>达梦数据库配置SSL认证加密</title>
		<link>https://www.lemonary.cn/%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e9%85%8d%e7%bd%aessl%e8%ae%a4%e8%af%81%e5%8a%a0%e5%af%86/</link>
					<comments>https://www.lemonary.cn/%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e9%85%8d%e7%bd%aessl%e8%ae%a4%e8%af%81%e5%8a%a0%e5%af%86/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Tue, 10 Jun 2025 09:08:24 +0000</pubDate>
				<category><![CDATA[DM]]></category>
		<category><![CDATA[SSL]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1955</guid>

					<description><![CDATA[原文地址：https://eco.dameng.com/community/article/af22b724d [&#8230;]]]></description>
										<content:encoded><![CDATA[
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">原文地址：<br><a href="https://eco.dameng.com/community/article/af22b724ddb048f400003a7312122f28">https://eco.dameng.com/community/article/af22b724ddb048f400003a7312122f28</a><br><a href="https://eco.dameng.com/community/article/c068d29ff069a34dc029fe9247c48796">https://eco.dameng.com/community/article/c068d29ff069a34dc029fe9247c48796</a></p>
</blockquote>



<h2 class="wp-block-heading">一、环境介绍</h2>



<p class="wp-block-paragraph">OS Version：CentOS Linux 8.2</p>



<p class="wp-block-paragraph">DB Version：DM V8 1-3-26-2023.06.14-193125-20046-ENT</p>



<p class="wp-block-paragraph">OpenSSL：OpenSSL 1.1.1k</p>



<p class="wp-block-paragraph">JAVA：openjdk version &#8220;1.8.0_332&#8221;</p>



<p class="wp-block-paragraph">参考手册：《DM8_DISQL使用手册》《DM8安全管理》《DM8程序员手册》</p>



<p class="wp-block-paragraph"><a href="https://eco.dameng.com/docs/zh-cn/pm/" target="_blank" rel="noreferrer noopener">DM8 产品手册 | 达梦技术社区</a></p>



<h2 class="wp-block-heading">二、配置过程</h2>



<h3 class="wp-block-heading">2.1 配置openssl配置文件</h3>



<p class="wp-block-paragraph">KylinV10 SP1或者Centos 7默认配置文件为/etc/pki/tls/openssl.cnf。也可以单独创建一个配置文件，在操作时指定该配置文件。</p>



<p class="wp-block-paragraph">备份openssl.cnf文件，并修改[ CA_default ]这一段内容部分配置项，其余默认。</p>



<pre class="wp-block-code"><code>&#91; CA_default ]

dir		= /opt/ca		# Where everything is kept
certs		= $dir/certs		# Where the issued certs are kept
crl_dir		= $dir/crl		# Where the issued crl are kept
database	= $dir/index.txt	# database index file.
#unique_subject	= no			# Set to 'no' to allow creation of
					# several certs with same subject.
new_certs_dir	= $dir/newcerts		# default place for new certs.

certificate	= $dir/ca-cert.pem 	# The CA certificate
serial		= $dir/serial 		# The current serial number
crlnumber	= $dir/crlnumber	# the current crl number
					# must be commented out to leave a V1 CRL
crl		= $dir/crl.pem 		# The current CRL
private_key	= $dir/ca-key.pem       # The private key

x509_extensions	= usr_cert		# The extensions to add to the cert</code></pre>



<h3 class="wp-block-heading">2.2 创建配置文件中对应的主要目录和文件</h3>



<pre class="wp-block-code"><code>&#91;root@shine ~]# mkdir -p /opt/ca
&#91;root@shine ~]# cd /opt/ca
&#91;root@shine ca]# mkdir {certs,crl,newcerts}
&#91;root@shine ca]# echo "01" &gt; serial
&#91;root@shine ca]# touch index.txt
##创建达梦数据库服务器和客户端证书文件存放目录
&#91;root@shine ca]# mkdir server_ssl
&#91;root@shine ca]# mkdir client_ssl
##创建SYSDBA用户客户端证书存放目录，其他用户请创建与用户名相同的目录
&#91;root@shine ca]# mkdir -p client_ssl/SYSDBA  </code></pre>



<h3 class="wp-block-heading">2.3 生成CA私钥和根证书</h3>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl req -new -x509 -days 3650 -keyout ca-key.pem -out ca-cert.pem -subj "/C=cn/ST=Beijing/L=Beijing/O=dameng/OU=server/CN=shine/emailAddress=shine@dm.com"
Generating a RSA private key
.....................................................................................+++++
......................................+++++
writing new private key to 'ca-key.pem'
Enter PEM pass phrase:                        #设置CA私钥的存储密码，本次测试设置为123456
Verifying - Enter PEM pass phrase:
-----
&#91;root@shine ca]# ls
ca-cert.pem  ca-key.pem  certs  client_ssl  crl  index.txt  newcerts  serial  server_ssl</code></pre>



<p class="wp-block-paragraph">ca-key.pem 为私钥文件，ca-cert.pem为根证书</p>



<p class="wp-block-paragraph">文件后缀简要说明：</p>



<ul class="wp-block-list">
<li>.key ： 私钥文件, 也可以使用“.pem”后缀。“.pem”后缀时，通常文件包含证书和私钥中的一种或者多种</li>



<li>.csr : 证书签名请求（证书请求文件），含有公钥信息，certificate signing request的缩写</li>



<li>.crl : 证书吊销列表，Certificate Revocation List的缩写</li>
</ul>



<p class="wp-block-paragraph">subj选项说明：</p>



<ul class="wp-block-list">
<li>Country Name : 缩写为“C” 证书持有者所在国家 要求填写国家代码</li>



<li>State or Province Name : 缩写为“ST“ 证书持有者所在州或省份</li>



<li>Locality Name : 缩写为“L” 证书持有者所在城市</li>



<li>Organization Name : 缩写为“O“ 证书持有者所属组织或公司</li>



<li>Organizational Unit Name : 缩写为“OU” 证书持有者所属部门</li>



<li>Common Name : 缩写为“CN“ 证书持有者的通用名</li>



<li>Email Address : 证书持有者的通信邮箱</li>
</ul>



<h3 class="wp-block-heading">2.4 生成服务器私钥和被CA签名的证书</h3>



<h4 class="wp-block-heading">2.4.1 生成私钥文件</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl genrsa -out server_ssl/server-key.pem
Generating RSA private key, 2048 bit long modulus (2 primes)
.................................................................................................................+++++
..............................................................+++++
e is 65537 (0x010001)

##注意服务器端的私钥，为了方便不设置加密</code></pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph"><strong>注意：</strong><br>如果服务端的私钥是带存储密码的，那么启动服务器的时候一定要使用命令行方式来启动，即<code>dmserver c:\dmdbms\data\DAMENG\dm.ini</code>，否则不能开启通信加密认证，因为只有这种方式才会让输入服务端私钥的密码。</p>
</blockquote>



<h4 class="wp-block-heading">2.4.2 生成证书签发申请</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl req -new -key server_ssl/server-key.pem -out server_ssl/server.csr -subj "/C=cn/ST=Beijing/L=Beijing/O=dameng/OU=server/CN=shine/emailAddress=shine@dm.com"</code></pre>



<h4 class="wp-block-heading">2.4.3 使用根证书和签发申请生成证书</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl ca -days 3650 -in server_ssl/server.csr -out server_ssl/server-cert.pem
Using configuration from /etc/pki/tls/openssl.cnf
Enter pass phrase for /opt/ca/ca-key.pem:                #输入生成CA私钥时设置的存储密码，上面设置的是123456
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Aug 11 09:23:40 2021 GMT
            Not After : Aug  9 09:23:40 2031 GMT
        Subject:
            countryName               = cn
            stateOrProvinceName       = Beijing
            organizationName          = dameng
            organizationalUnitName    = server
            commonName                = shine
            emailAddress              = shine@dm.com
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                46:E9:80:E8:CC:1D:7E:DB:E3:05:FF:8C:3B:77:43:51:9B:16:05:43
            X509v3 Authority Key Identifier: 
                keyid:61:05:BE:3F:A9:DE:2D:9A:7F:2A:BA:0E:45:97:47:5B:E8:0C:D7:7E

Certificate is to be certified until Aug  9 09:23:40 2031 GMT (3650 days)
Sign the certificate? &#91;y/n]:y                       #输入y


1 out of 1 certificate requests certified, commit? &#91;y/n]y      #输入y
Write out database with 1 new entries
Data Base Updated</code></pre>



<h4 class="wp-block-heading">2.4.4 将证书格式转换为x509格式</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl x509 -in server_ssl/server-cert.pem -out server_ssl/server.cer
&#91;root@shine ca]# ll server_ssl/
total 28
-rwxrwxrwx 1 root root 1407 Jun 10 13:56 ca-cert.pem
-rwxrwxrwx 1 root root 1854 Jun 10 13:56 ca-key.pem
-rwxrwxrwx 1 root root 1411 Jun 10 13:54 server.cer
-rwxrwxrwx 1 root root 4572 Jun 10 13:54 server-cert.pem
-rwxrwxrwx 1 root root 1037 Jun 10 13:54 server.csr
-rwxrwxrwx 1 root root 1675 Jun 10 13:54 server-key.pem</code></pre>



<h4 class="wp-block-heading">2.4.5 将CA自签名的证书拷贝到server_ssl目录中</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# cp ca-cert.pem server_ssl/
&#91;root@shine ca]# cp ca-key.pem server_ssl/</code></pre>



<h3 class="wp-block-heading">2.5 生成客户端用户私钥和被CA签名的证书</h3>



<h4 class="wp-block-heading">2.5.1 生成私钥文件</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl genrsa -aes256 -out client_ssl/SYSDBA/client-key.pem
Generating RSA private key, 2048 bit long modulus (2 primes)
............................+++++
..+++++
e is 65537 (0x010001)
Enter pass phrase for client_ssl/SYSDBA/client-key.pem:               #设置私钥密码，本次测试设置为dameng
Verifying - Enter pass phrase for client_ssl/SYSDBA/client-key.pem:  #再输入一次

#-aes256表示使用AES算法对产生的私钥加密</code></pre>



<h4 class="wp-block-heading">2.5.2 生成证书签发申请</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl req -new -key client_ssl/SYSDBA/client-key.pem -out client_ssl/SYSDBA/client.csr -subj "/C=cn/ST=Beijing/L=Beijing/O=dameng/OU=server/CN=SYSDBA/emailAddress=dmclient@dm.com"
Enter pass phrase for client_ssl/SYSDBA/client-key.pem:  #输入上一步生成私钥文件时设置的密码</code></pre>



<h4 class="wp-block-heading">2.5.3 使用根证书和签发申请生成证书</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl ca -days 365 -in client_ssl/SYSDBA/client.csr -out client_ssl/SYSDBA/client-cert.pem
Using configuration from /etc/pki/tls/openssl.cnf
Enter pass phrase for /opt/ca/ca-key.pem:         #输入设置的CA私钥存储密码
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 2 (0x2)
        Validity
            Not Before: Aug 11 09:39:23 2021 GMT
            Not After : Aug 11 09:39:23 2022 GMT
        Subject:
            countryName               = cn
            stateOrProvinceName       = Beijing
            organizationName          = dameng
            organizationalUnitName    = server
            commonName                = SYSDBA
            emailAddress              = dmclient@dm.com
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                E1:BB:5E:A0:E6:7C:38:40:FD:BB:6B:B8:2E:6E:2C:46:1C:E3:AF:1C
            X509v3 Authority Key Identifier: 
                keyid:61:05:BE:3F:A9:DE:2D:9A:7F:2A:BA:0E:45:97:47:5B:E8:0C:D7:7E

Certificate is to be certified until Aug 11 09:39:23 2022 GMT (365 days)
Sign the certificate? &#91;y/n]:y                #输入y


1 out of 1 certificate requests certified, commit? &#91;y/n]y        #输入y
Write out database with 1 new entries
Data Base Updated</code></pre>



<h4 class="wp-block-heading">2.5.4 转换client-pkcs.p12</h4>



<p class="wp-block-paragraph">将生成的X509格式的client-key.pem和client-cert.pem合并转换为pkcs12格式的文件client-pkcs.p12</p>



<pre class="wp-block-code"><code>&#91;root@shine ca]# openssl pkcs12 -export -inkey client_ssl/SYSDBA/client-key.pem -in client_ssl/SYSDBA/client-cert.pem -out client_ssl/SYSDBA/client-pkcs.p12
Enter pass phrase for client_ssl/SYSDBA/client-key.pem:    #输入之前设置的客户端私钥存储密码（dameng）
Enter Export Password:            #设置export password，本次测试设置为abc123
Verifying - Enter Export Password: #再输入一次</code></pre>



<h4 class="wp-block-heading">2.5.5 生成JDBC访问需要的.keystore文件</h4>



<p class="wp-block-paragraph">导入所有证书到keystore文件，并设置keystore文件密码为abc123（-deststorepass）</p>



<pre class="wp-block-code"><code>&#91;root@shine ca]# keytool -import -alias ca -trustcacerts -file ca-cert.pem -keystore client_ssl/SYSDBA/.keystore -deststorepass abc123 -noprompt
证书已添加到密钥库中
&#91;root@shine ca]# keytool -import -alias server -trustcacerts -file server_ssl/server.cer -keystore client_ssl/SYSDBA/.keystore -deststorepass abc123 -noprompt
证书已添加到密钥库中
&#91;root@shine ca]# keytool -importkeystore -srckeystore client_ssl/SYSDBA/client-pkcs.p12 -srcstorepass abc123  -srcstoretype PKCS12 -keystore client_ssl/SYSDBA/.keystore  -deststorepass abc123
正在将密钥库 client_ssl/SYSDBA/client-pkcs.p12 导入到 client_ssl/SYSDBA/.keystore...
已成功导入别名 1 的条目。
已完成导入命令: 1 个条目成功导入, 0 个条目失败或取消

Warning:
JKS 密钥库使用专用格式。建议使用 "keytool -importkeystore -srckeystore client_ssl/SYSDBA/.keystore -destkeystore client_ssl/SYSDBA/.keystore -deststoretype pkcs12" 迁移到行业标准格式 PKCS12。</code></pre>



<p class="wp-block-paragraph">执行上面警告的内容：（可选）</p>



<pre class="wp-block-code"><code>&#91;root@shine ca]# keytool -importkeystore -srckeystore client_ssl/SYSDBA/.keystore -destkeystore client_ssl/SYSDBA/.keystore -deststoretype pkcs12
输入源密钥库口令:           #输入之前的export password，abc123
已成功导入别名 ca 的条目。
已成功导入别名 1 的条目。
已成功导入别名 server 的条目。
已完成导入命令: 3 个条目成功导入, 0 个条目失败或取消

Warning:
已将 "client_ssl/SYSDBA/.keystore" 迁移到 Non JKS/JCEKS。将 JKS 密钥库作为 "client_ssl/SYSDBA/.keystore.old" 进行了备份。</code></pre>



<h4 class="wp-block-heading">2.5.6 将CA自签名的证书拷贝到client_ssl/SYSDBA目录中</h4>



<pre class="wp-block-code"><code>&#91;root@shine ca]# cp ca-cert.pem client_ssl/SYSDBA/
&#91;root@shine ca]# ls -la client_ssl/SYSDBA/
total 48
drwxrwxrwx 2 root root 4096 Jun 10 14:13 .
drwxrwxrwx 3 root root 4096 Jun 10 13:41 ..
-rwxrwxrwx 1 root root 1407 Jun 10 14:13 ca-cert.pem
-rwxrwxrwx 1 root root 4580 Jun 10 14:01 client-cert.pem
-rwxrwxrwx 1 root root 1045 Jun 10 14:00 client.csr
-rwxrwxrwx 1 root root 1766 Jun 10 13:58 client-key.pem
-rwxrwxrwx 1 root root 2605 Jun 10 14:01 client-pkcs.p12
-rwxrwxrwx 1 root root 4869 Jun 10 14:12 .keystore
-rwxrwxrwx 1 root root 4411 Jun 10 14:12 .keystore.old</code></pre>



<h3 class="wp-block-heading">2.6 部署SERVER端证书</h3>



<p class="wp-block-paragraph">将/opt/ca/server_ssl整个目录拷贝到达梦数据库安装目录下的bin目录下，默认在bin目录下存在server_ssl目录。可以先将默认的server_ssl目录重命名，然后拷贝。</p>



<pre class="wp-block-code"><code>&#91;root@shine ca]# cd /home/dmdba/dmdbms/bin
&#91;root@shine bin]# mv server_ssl server_ssl_bak2
&#91;root@shine bin]# cp /opt/ca/server_ssl ./ -r
&#91;root@shine bin]# chmod -R 777 server_ssl
&#91;root@shine bin]# ll server_ssl
total 28
-rwxrwxrwx 1 root root 1407 Jun 10 14:13 ca-cert.pem
-rwxrwxrwx 1 root root 1854 Jun 10 14:13 ca-key.pem
-rwxrwxrwx 1 root root 1411 Jun 10 14:13 server.cer
-rwxrwxrwx 1 root root 4572 Jun 10 14:13 server-cert.pem
-rwxrwxrwx 1 root root 1037 Jun 10 14:13 server.csr
-rwxrwxrwx 1 root root 1675 Jun 10 14:13 server-key.pem</code></pre>



<h3 class="wp-block-heading">2.7 部署client端证书</h3>



<p class="wp-block-paragraph">将/opt/ca/client_ssl整个目录拷贝到客户端机器上。如果是Linux机器，需要注意目录权限，可以将整个目录设置为777权限。</p>



<pre class="wp-block-code"><code>chmod 777 -R client_ssl</code></pre>



<p class="wp-block-paragraph">如果是通过jdbc接口来加密访问数据库，是使用的.keystore文件；</p>



<p class="wp-block-paragraph">如果是通过ODBC或者其他方式加密访问数据库，那么是使用ca-cert.pem、client-cert.pem和client-key.pem三个文件。</p>



<h3 class="wp-block-heading">2.8 数据库启用SSL认证和通信加密</h3>



<p class="wp-block-paragraph">是否使用通信加密以DM数据库服务器端的设置为准，即通过设置服务器配置文件dm.ini中的ENABLE_ENCRYPT或者COMM_ENCRYPT_NAME参数来指定，ENABLE_ENCRYPT可以开启<strong>传输层</strong>通讯加密，COMM_ENCRYPT_NAME可以开启<strong>应用层</strong>消息通讯加密，两个层次上的加密是互不干扰，互不影响，可以同时开启这两个层次上的加密，也可以开启其中一个，如果开启传输层消息加密需要配置SSL证书。客户端以服务器采用的通信方式与其进行通信。</p>



<p class="wp-block-paragraph">ENABLE_ENCRYPT：取值0、1和2，含义义分别为：</p>



<p class="wp-block-paragraph">0表示在<strong>传输层</strong>不开启SSL认证和SSL通信加密；<br>1表示在<strong>传输层</strong>开启SSL认证和SSL通信加密；<br>2表示在<strong>传输层</strong>仅开启SSL认证,但不开启SSL加密。</p>



<p class="wp-block-paragraph">COMM_ENCRYPT_NAME参数用来指定<strong>应用层</strong>消息通信的加密算法名，指定加密算法后，即可开启应用层通信加密（无需配置ENABLE_ENCRYPT）。如果为空则不进行通信加密；如果给的加密算法名错误，则使用加密算法DES_CFB。应用层的这种加密非常适合两端缺少数字证书的情况。<br>DM支持的加密算法名可以通过查询动态视图V$CIPHERS获取。</p>



<p class="wp-block-paragraph">修改数据库参数：</p>



<pre class="wp-block-code"><code>---开启应用层通讯加密（测试通讯加密）
SQL&gt; SF_SET_SYSTEM_PARA_VALUE('COMM_ENCRYPT_NAME','RC4',1,2);
DMSQL 过程已成功完成
已用时间: 7.093(毫秒). 执行号:500.

---开启SSL认证（测试SSL认证登录）
SQL&gt; SF_SET_SYSTEM_PARA_VALUE('ENABLE_ENCRYPT',2,1,2);
DMSQL 过程已成功完成
已用时间: 5.268(毫秒). 执行号:501.
SQL&gt; SELECT * FROM V$PARAMETER WHERE NAME='ENABLE_ENCRYPT' OR NAME='COMM_ENCRYPT_NAME';

行号     ID          NAME              TYPE    VALUE SYS_VALUE FILE_VALUE
---------- ----------- ----------------- ------- ----- --------- ----------
           DESCRIPTION                                                                                 
           --------------------------------------------------------------------------------------------
1          454         ENABLE_ENCRYPT    IN FILE 0     0         2
           Encrypt Mode For Communication, 0: Without Encryption; 1: SSL Encryption; 2: SSL Authentication

2          476         COMM_ENCRYPT_NAME IN FILE                 RC4
           Communication encrypt name, if it is null then the communication is not encrypted</code></pre>



<p class="wp-block-paragraph">重启数据库生效。</p>



<h2 class="wp-block-heading">三、SSL认证登录测试</h2>



<p class="wp-block-paragraph">如果是通过jdbc接口来加密访问数据库，是使用的.keystore文件，所以SSL认证密码是keystore文件的密码；</p>



<p class="wp-block-paragraph">如果是通过ODBC或者其他方式加密访问数据库，那么是使用ca-cert.pem、client-cert.pem和client-key.pem三个文件，所以SSL密码为客户端私钥密码。</p>



<h3 class="wp-block-heading">3.1 disql工具登录</h3>



<pre class="wp-block-code"><code>&#91;dmdba@shine ~]$ disql SYSDBA/'"Dameng@!23"'@localhost:5236#"{SSL_PATH=/opt/ca/client_ssl/SYSDBA,SSL_PWD=dameng}"

Server&#91;localhost:5236]:mode is normal, state is open
login used time : 9.523(ms)
disql V8
SQL&gt; exit
## 或者
&#91;dmdba@shine ~]$ disql /nolog
disql V8
SQL&gt; login
server:localhost
username:SYSDBA
password:
SSL path:/opt/ca/client_ssl/SYSDBA
SSL PWD:
UKEY NAME:
UKEY PIN:
MPP TYPE:
read/write separate(y/n):
protocol type:

Server&#91;localhost:5236]:mode is normal, state is open
login used time : 9.058(ms)
SQL&gt; </code></pre>



<h3 class="wp-block-heading">3.2 管理工具登录</h3>



<p class="wp-block-paragraph">管理工具连接数据库的方式是通过JDBC，所以SSL密码为keystore文件密码，而非客户端私钥密码。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="647" height="611" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-22.png" alt="" class="wp-image-1957" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-22.png 647w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-22-300x283.png 300w" sizes="(max-width: 647px) 100vw, 647px" /></figure>



<p class="wp-block-paragraph">这里的密码使用的是keystore文件的密码（abc123）</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="612" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-23-1024x612.png" alt="" class="wp-image-1958" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-23-1024x612.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-23-300x179.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-23-768x459.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-23-1536x918.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-23-2048x1224.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.3 JDBC程序连接配置</h3>



<p class="wp-block-paragraph">JDBC通过SSL认证方式登录数据库需要添加连接串属性sslFilesPath和sslKeystorePass，简要配置如下：</p>



<pre class="wp-block-code"><code>String name="dm.jdbc.driver.DmDriver";
String url="jdbc:dm://ip:5236?sslFilesPath=C:\\dmdbms\\bin\\client_ssl\\SYSDBA&amp;sslKeystorePass=abc123";
String user="SYSDBA";
String password="SYSDBA";</code></pre>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="571" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-24-1024x571.png" alt="" class="wp-image-1959" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-24-1024x571.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-24-300x167.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-24-768x429.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-24.png 1113w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.4 逻辑导出导入</h3>



<pre class="wp-block-code"><code>&#91;dmdba@shine ~]$ dexp USERID=SYSDBA/SYSDBA@localhost:5236#"{SSL_PATH=/opt/ca/client_ssl/SYSDBA,SSL_PWD=dameng}" FILE=FULL.DMP LOG=EXP.LOG DIRECTORY=./ FULL=Y ROWS=Y</code></pre>



<h3 class="wp-block-heading">3.5 SQLark连接</h3>



<pre class="wp-block-code"><code>URL
jdbc:dm://ip:port?sslFilesPath=D:\client_ssl\SYSDBA&amp;sslKeystorePass=123456</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="903" height="1024" src="https://www.lemonary.cn/wp-content/uploads/2025/06/企业微信截图_fc043b35-d4db-4ccf-a597-e08b953423531-903x1024.png" alt="" class="wp-image-2002" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/企业微信截图_fc043b35-d4db-4ccf-a597-e08b953423531-903x1024.png 903w, https://www.lemonary.cn/wp-content/uploads/2025/06/企业微信截图_fc043b35-d4db-4ccf-a597-e08b953423531-265x300.png 265w, https://www.lemonary.cn/wp-content/uploads/2025/06/企业微信截图_fc043b35-d4db-4ccf-a597-e08b953423531-768x871.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/企业微信截图_fc043b35-d4db-4ccf-a597-e08b953423531-1354x1536.png 1354w, https://www.lemonary.cn/wp-content/uploads/2025/06/企业微信截图_fc043b35-d4db-4ccf-a597-e08b953423531.png 1700w" sizes="auto, (max-width: 903px) 100vw, 903px" /></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e9%85%8d%e7%bd%aessl%e8%ae%a4%e8%af%81%e5%8a%a0%e5%af%86/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>网站SSL证书过期替换手册</title>
		<link>https://www.lemonary.cn/%e7%bd%91%e7%ab%99ssl%e8%af%81%e4%b9%a6%e8%bf%87%e6%9c%9f%e6%9b%bf%e6%8d%a2%e6%89%8b%e5%86%8c/</link>
					<comments>https://www.lemonary.cn/%e7%bd%91%e7%ab%99ssl%e8%af%81%e4%b9%a6%e8%bf%87%e6%9c%9f%e6%9b%bf%e6%8d%a2%e6%89%8b%e5%86%8c/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Tue, 03 Jun 2025 02:19:44 +0000</pubDate>
				<category><![CDATA[建站记录]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[SSL]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1903</guid>

					<description><![CDATA[一、前言 本站使用的是FreeSSL网站提供的免费证书，由于证书的有效期是三个月，所以每三个月就需要替换一次新 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、前言</h2>



<p class="wp-block-paragraph">本站使用的是FreeSSL网站提供的免费证书，由于证书的有效期是三个月，所以每三个月就需要替换一次新的证书。因此，特此记录下替换证书的整个过程，以便后续替换时参考。</p>



<h2 class="wp-block-heading">二、替换步骤</h2>



<h3 class="wp-block-heading">2.1 申请证书</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1024x549.png" alt="" class="wp-image-1905" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">选择单域名类型即可</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-1024x549.png" alt="" class="wp-image-1906" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">填写证书域名，点击提交</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-1024x549.png" alt="" class="wp-image-1907" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">此时会跳转到KeyManager，若此前并未安装直接选择下载安装，然后同样跳转到KeyManager，此时KeyManager会弹出如下窗口</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="640" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-1024x640.png" alt="" class="wp-image-1908" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-1024x640.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-300x187.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-768x480.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-1536x960.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-2048x1280.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">2.2 添加DNS解析</h3>



<p class="wp-block-paragraph">然后返回浏览器继续操作，点击继续，然后会弹出如下窗口</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-1024x549.png" alt="" class="wp-image-1910" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">这是一条DNS解析，将此条解析添加到服务器域名的解析列表中（我的域名注册于华为云平台），按上述图片内容配置红框位置后，确认，完成添加。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-1024x549.png" alt="" class="wp-image-1911" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">再回到FREESSL，点击我已配置完成后回到订单列表可以看到刚刚申请的证书</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="217" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-1024x217.png" alt="" class="wp-image-1912" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-1024x217.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-300x64.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-768x163.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-1536x325.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-2048x434.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">点击验证，进行验证刚刚添加的DNS解析，验证成功后如下</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="250" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-1024x250.png" alt="" class="wp-image-1914" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-1024x250.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-300x73.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-768x188.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-1536x375.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-2048x500.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">2.3 KeyManager一键部署</h3>



<p class="wp-block-paragraph">点击保存到KeyManager，便可将证书保存到客户端软件，后续便可一键部署</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="668" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-1024x668.png" alt="" class="wp-image-1915" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-1024x668.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-300x196.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-768x501.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-1536x1002.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10.png 1725w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">一键部署前需要配置部署信息，选择服务器类型，用户名、主机名、端口、证书存放路径、私钥存放路径、重载命令、服务器密码</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="780" height="840" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-11.png" alt="" class="wp-image-1916" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-11.png 780w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-11-279x300.png 279w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-11-768x827.png 768w" sizes="auto, (max-width: 780px) 100vw, 780px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="778" height="840" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-12.png" alt="" class="wp-image-1917" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-12.png 778w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-12-278x300.png 278w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-12-768x829.png 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></figure>



<p class="wp-block-paragraph">配置完成后便可进行一键部署，刷新网页查看证书信息是否生效</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="817" height="1008" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-13.png" alt="" class="wp-image-1918" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-13.png 817w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-13-243x300.png 243w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-13-768x948.png 768w" sizes="auto, (max-width: 817px) 100vw, 817px" /></figure>



<p class="wp-block-paragraph">至此，证书替换完成。</p>



<h2 class="wp-block-heading">三、自动化管理</h2>



<p class="wp-block-paragraph">FreeSSL网站提供了自动化管理功能</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-1024x549.png" alt="" class="wp-image-1921" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.1 域名预授权</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="587" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-1024x587.png" alt="" class="wp-image-1922" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-1024x587.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-300x172.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-768x440.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-15.png 1044w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="917" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-1024x917.png" alt="" class="wp-image-1923" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-1024x917.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-300x269.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-768x688.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-16.png 1042w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">同样配置好DNS解析（这个过程参考上边）后点击配置完成，立即检测，验证通过后如下</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-1024x549.png" alt="" class="wp-image-1924" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.2 申请证书</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="512" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-1024x512.png" alt="" class="wp-image-1925" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-1024x512.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-300x150.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-768x384.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-18.png 1101w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.3 设置参数</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="514" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-1024x514.png" alt="" class="wp-image-1926" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-1024x514.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-300x151.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-768x385.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-19.png 1102w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">/usr/local/nginx/ssl/full_chain.pem<br>/usr/local/nginx/ssl/private.key</p>



<h3 class="wp-block-heading">3.4 客户端部署</h3>



<p class="wp-block-paragraph">最后会显示安装部署客户端的步骤，依次执行</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="802" height="1024" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-802x1024.png" alt="" class="wp-image-1927" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-802x1024.png 802w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-235x300.png 235w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-768x980.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-20.png 1096w" sizes="auto, (max-width: 802px) 100vw, 802px" /></figure>



<h4 class="wp-block-heading">3.4.1 客户端初始化（首次使用）</h4>



<p class="wp-block-paragraph"><strong>a.下载客户端</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine ~]# curl https://get.acme.sh | sh -s email=leonshinel@163.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1032    0  1032    0     0    677      0 --:--:--  0:00:01 --:--:--   676
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  221k  100  221k    0     0   733k      0 --:--:-- --:--:-- --:--:--  733k
&#91;Tue Jun  3 10:39:19 CST 2025] Installing from online archive.
&#91;Tue Jun  3 10:39:19 CST 2025] Downloading https://github.com/acmesh-official/acme.sh/archive/master.tar.gz
&#91;Tue Jun  3 10:39:21 CST 2025] Extracting master.tar.gz
&#91;Tue Jun  3 10:39:21 CST 2025] It is recommended to install socat first.
&#91;Tue Jun  3 10:39:21 CST 2025] We use socat for the standalone server, which is used for standalone mode.
&#91;Tue Jun  3 10:39:21 CST 2025] If you don't want to use standalone mode, you may ignore this warning.
&#91;Tue Jun  3 10:39:21 CST 2025] Installing to /root/.acme.sh
&#91;Tue Jun  3 10:39:21 CST 2025] Installed to /root/.acme.sh/acme.sh
&#91;Tue Jun  3 10:39:21 CST 2025] Installing alias to '/root/.bashrc'
&#91;Tue Jun  3 10:39:21 CST 2025] Close and reopen your terminal to start using acme.sh
&#91;Tue Jun  3 10:39:21 CST 2025] Installing alias to '/root/.cshrc'
&#91;Tue Jun  3 10:39:21 CST 2025] Installing alias to '/root/.tcshrc'
&#91;Tue Jun  3 10:39:21 CST 2025] Installing cron job
&#91;Tue Jun  3 10:39:21 CST 2025] bash has been found. Changing the shebang to use bash as preferred.
&#91;Tue Jun  3 10:39:22 CST 2025] OK
&#91;Tue Jun  3 10:39:22 CST 2025] Install success!</code></pre>



<p class="wp-block-paragraph"><strong>b.注册 ACME 账户</strong></p>



<p class="wp-block-paragraph">不知道为啥第一步环境变量没配上，不过没关系，直接进到目录中进行执行即可</p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# pwd
/root/.acme.sh
&#91;root@shine .acme.sh]# ./acme.sh --register-account --server https://acmepro.freessl.cn/v2/DV --eab-kid aWm2G_OMBrVt9Ssk_79fnR_cwuUNxvZFAoHm-rTXR3g --eab-hmac-key MD8CAQACCQCm9eI054tO9wIDAQABAggquQyS1v0oAQIFAN6O_gECBQDADDz3AgUA2apAAQIFAKls4ocCBDvEWoM
&#91;Tue Jun  3 10:41:37 CST 2025] Account key creation OK.
&#91;Tue Jun  3 10:41:38 CST 2025] Registering account: https://acmepro.freessl.cn/v2/DV
&#91;Tue Jun  3 10:41:38 CST 2025] Registered
&#91;Tue Jun  3 10:41:38 CST 2025] ACCOUNT_THUMBPRINT='yKX_KD_1TBhifHZdiFhvFb4Ljjl3Lw7VYlNn2xB7-EA'</code></pre>



<h4 class="wp-block-heading">3.4.2 申请部署证书</h4>



<p class="wp-block-paragraph"><strong>a.申请证书</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# ./acme.sh --issue --dns dns_tencent -d www.lemonary.cn --server https://acmepro.freessl.cn/v2/DV
&#91;Tue Jun  3 10:43:52 CST 2025] Using CA: https://acmepro.freessl.cn/v2/DV
&#91;Tue Jun  3 10:43:52 CST 2025] Creating domain key
&#91;Tue Jun  3 10:43:52 CST 2025] The domain key is here: /root/.acme.sh/www.lemonary.cn_ecc/www.lemonary.cn.key
&#91;Tue Jun  3 10:43:52 CST 2025] Single domain='www.lemonary.cn'
&#91;Tue Jun  3 10:44:01 CST 2025] Getting webroot for domain='www.lemonary.cn'
&#91;Tue Jun  3 10:44:02 CST 2025] www.lemonary.cn is already verified, skipping dns-01.
&#91;Tue Jun  3 10:44:02 CST 2025] Verification finished, beginning signing.
&#91;Tue Jun  3 10:44:02 CST 2025] Let's finalize the order.
&#91;Tue Jun  3 10:44:02 CST 2025] Le_OrderFinalize='https://acmepro.freessl.cn/v2/finalize/Np1GjvLl'
&#91;Tue Jun  3 10:44:08 CST 2025] Order status is 'processing', let's sleep and retry.
&#91;Tue Jun  3 10:44:11 CST 2025] Polling order status: https://acmepro.freessl.cn/v2/order/Np1GjvLl
&#91;Tue Jun  3 10:44:13 CST 2025] Downloading cert.
&#91;Tue Jun  3 10:44:13 CST 2025] Le_LinkCert='https://acmepro.freessl.cn/v2/cert/75847FE7968914EAC292FF5E8E50CDCCF9D62904'
&#91;Tue Jun  3 10:44:14 CST 2025] Cert success.</code></pre>



<p class="wp-block-paragraph"><strong>b.部署证书</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# ./acme.sh --install-cert -d www.lemonary.cn --fullchain-file /usr/local/nginx/ssl/full_chain.pem --key-file /usr/local/nginx/ssl/private.key --reloadcmd "nginx -s reload" 
&#91;Tue Jun  3 10:44:38 CST 2025] The domain 'www.lemonary.cn' seems to already have an ECC cert, let's use it.
&#91;Tue Jun  3 10:44:38 CST 2025] Installing key to: /usr/local/nginx/ssl/private.key
&#91;Tue Jun  3 10:44:38 CST 2025] Installing full chain to: /usr/local/nginx/ssl/full_chain.pem
&#91;Tue Jun  3 10:44:38 CST 2025] Running reload cmd: nginx -s reload
&#91;Tue Jun  3 10:44:38 CST 2025] Reload successful</code></pre>



<p class="wp-block-paragraph"><strong>c.确认开启自动续期</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# crontab -l | grep acme
21 15 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" &gt; /dev/null</code></pre>



<p class="wp-block-paragraph">至此，证书的自动化管理已经配置完成。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e7%bd%91%e7%ab%99ssl%e8%af%81%e4%b9%a6%e8%bf%87%e6%9c%9f%e6%9b%bf%e6%8d%a2%e6%89%8b%e5%86%8c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>站点健康之HTTP与HTTPS</title>
		<link>https://www.lemonary.cn/%e7%ab%99%e7%82%b9%e5%81%a5%e5%ba%b7%e4%b9%8bhttp%e4%b8%8ehttps/</link>
					<comments>https://www.lemonary.cn/%e7%ab%99%e7%82%b9%e5%81%a5%e5%ba%b7%e4%b9%8bhttp%e4%b8%8ehttps/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Mon, 02 Dec 2024 09:31:59 +0000</pubDate>
				<category><![CDATA[建站记录]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=711</guid>

					<description><![CDATA[一、概述 不需要了解太详细，我们只需要知道HTTPS比HTTP更安全。简单来说 HTTPS 是 HTTP 的安 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="一、概述">一、概述</h2>



<p class="wp-block-paragraph">不需要了解太详细，我们只需要知道HTTPS比HTTP更安全。简单来说 HTTPS 是 HTTP 的安全版，是使用 TLS/SSL 加密的 HTTP 协议。</p>



<h2 class="wp-block-heading" id="二、把HTTP换成HTTPS">二、把HTTP换成HTTPS</h2>



<h3 class="wp-block-heading" id="2.1-申请证书">2.1 申请证书</h3>



<p class="wp-block-paragraph">免费的，花钱的都可以，能够把证书申请下来就可以。各种云厂商都提供SSL证书服务，例如：<a href="https://www.aliyun.com/">阿里云</a>、<a href="https://cloud.tencent.com/">腾讯云</a>、<a href="https://www.huaweicloud.com/">华为云</a>……也可以用一些免费的，例如：<a href="https://letsencrypt.osfipin.com/">来此加密</a>、<a href="https://freessl.cn/">FREESSL</a>、<a href="https://www.cloudflare-cn.com/">Cloudflare</a>等等。</p>



<p class="wp-block-paragraph">申请证书的过程就不在此介绍了，在申请证书的网站一步一步照着做就可以。</p>



<p class="wp-block-paragraph">证书申请成功后，将证书文件下载，上传到服务器nginx目录。一般只需要上传证书中的证书链文件（fullchain.crt）和私钥文件（private.pem）。【证书文件名大多类似，名字或格式略有差别】</p>



<p class="wp-block-paragraph">我在nginx目录下创建了ssl文件夹，用于存放证书文件：</p>



<pre class="wp-block-code"><code>&#91;root@dameng ssl]# pwd
/usr/local/nginx/ssl
&#91;root@dameng ssl]# ll
total 20
-rw-r--r-- 1 root root 2836 Dec  2 13:29 fullchain.crt
-rw-r--r-- 1 root root 6372 Dec  2 16:47 full_chain.pem
-rw-r--r-- 1 root root 1732 Dec  2 16:47 private.key
-rw-r--r-- 1 root root  241 Dec  2 11:31 private.pem</code></pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">注意<br>我存放了两套证书，所以有四个文件，正常情况下有一套就可以。</p>
</blockquote>



<h3 class="wp-block-heading" id="2.2-修改nginx配置">2.2 修改nginx配置</h3>



<p class="wp-block-paragraph">编辑配置文件nginx.conf，只需要修改server部分就行</p>



<pre class="wp-block-code"><code>server {
        listen 80;
        server_name 你的域名;
        #将HTTP重定向到HTTPS
        return 301 https://$server_name$request_uri;
}
server
    {
        listen 443 ssl;
        ssl_stapling on;
        ssl_stapling_verify on;
        #请填写证书文件的相对路径或绝对路径
        ssl_certificate "/usr/local/nginx/ssl/full_chain.pem";
        #请填写私钥文件的相对路径或绝对路径
        ssl_certificate_key "/usr/local/nginx/ssl/private.key";
        
        #listen 80 default_server reuseport;
        #listen &#91;::]:80 default_server ipv6only=on;
        server_name 你的域名;
        ……
        ……
        ……</code></pre>



<p class="wp-block-paragraph">保存并重新加载nginx</p>



<pre class="wp-block-code"><code>&#91;root@dameng conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
&#91;root@dameng conf]# nginx -s reload</code></pre>



<h2 class="wp-block-heading" id="三、其他问题">三、其他问题</h2>



<p class="wp-block-paragraph">由于我在申请SSL证书的同一天将域名解析到我的IP（也就是网站IP与域名绑定），碰到了一些意料之外的问题：</p>



<ol class="wp-block-list">
<li>网站上所有的图片都加载不出来。</li>



<li>还有一个神奇的现象，就是页面加载后会把我底部音乐播放器的音乐封面铺满整个网页。</li>
</ol>



<p class="wp-block-paragraph">后续我也找到了解决的方法：准备工作是要下载一个插件<strong>Unlimited Elements for Elementor</strong>。</p>



<ol class="wp-block-list">
<li>图片加载不出来是因为图片都在WordPress媒体库并且图片的链接还是以前的IP链接，例如：https://xxx.xxx.xxx.xxx/wp-content/uploads/2024/11/头像-e1731570721610.jpg，需要将媒体库文件链接中所有的IP替换掉。当然不用一个一个的改，从WordPress的设置-常规里把<strong>WordPress地址（URL）</strong>和<strong>站点地址（URL）</strong>修改成域名。修改完成后，再次登录WordPress管理界面时，上述插件<strong>Unlimited Elements for Elementor</strong>会提示将网站从IP地址<strong>迁移</strong>到新的域名，点击<strong>迁移</strong>即可解决问题。</li>



<li>另外，音乐播放器封面的问题，我怀疑是我在申请SSL证书时没有填写顶级域名（lemonary.cn）而是只填了二级域名（www.lemonary.cn）导致的，我没有证实这一问题。但是在我将只填了二级域名的SSL证书替换掉后，这个现象也就没再出现过。</li>
</ol>



<p class="wp-block-paragraph">所以大家在替换域名和申请SSL证书时要注意以下两点：</p>



<ol class="wp-block-list">
<li>WordPress的媒体库中的文件链接需要修改，可以用插件统一修改。</li>



<li>SSL证书申请时一定要写好两个域名：顶级域名和二级域名（带www的和不带www的）。</li>
</ol>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e7%ab%99%e7%82%b9%e5%81%a5%e5%ba%b7%e4%b9%8bhttp%e4%b8%8ehttps/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
