2

替换 Windows RDP 的默认自签发证书

 2 years ago
source link: https://iecho.cc/2022/08/24/windows-replace-rdp-default-self-signed-certificate/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

替换 Windows RDP 的默认自签发证书

替换 Windows RDP 的默认自签发证书

2022-08-24 13:36:12

# 网络

在近年发布的 Windows 系统中,默认为 RDP 服务创建一封自签发证书以提供 TLS 安全。自签发证书是不被信任的,会在客户端侧抛出安全警告。我们可以使用 mkcert 创建可信的自签发证书,或者通过 Let’s Encrypt 等供应商签发免费的 SSL 证书,然后应用于 RDP 服务。

mkcert 为例,为 example.com 创建证书:

mkcert example.com

得到 example.com.pem(公钥)和 example.com-key.pem(私钥)等两个文件,并提示会在 2024 年过期。

Created a new certificate valid for the following names 📜
- "example.com"

The certificate is at "./example.com.pem" and the key at "./example.com-key.pem" ✅

It will expire on 24 November 2024 🗓

调用 openssl 包合并公钥私钥为单个 PKCS12 证书 example.com.p12,导出密码可以不填写。

openssl pkcs12 -export -clcerts -in example.com.pem -inkey example.com-key.pem -out example.com.p12

在 RDP 服务所在的电脑上,双击证书导入至 本地计算机 - 个人 存储区。随后,在证书的详细信息页面获取证书指纹(Fingerprint),也就是一串 SHA-1 哈希值。按下 Win + X 键,以管理员身份运行 Powershell,并输入下列命令以指定 RDP 证书。

wmic /namespace:\\root\cimv2\TerminalServices PATH Win32_TSGeneralSetting Set SSLCertificateSHA1Hash="<证书指纹>"

再使用 RDP 客户端建立连接,即可看到 RDP 服务已经应用指定的证书了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK