Skip to content

Instantly share code, notes, and snippets.

@pd12bbf7608ae1
Created August 12, 2020 08:23
Show Gist options
  • Save pd12bbf7608ae1/b4b6b97a0f9965f7b52e641865909a81 to your computer and use it in GitHub Desktop.
Save pd12bbf7608ae1/b4b6b97a0f9965f7b52e641865909a81 to your computer and use it in GitHub Desktop.
从PEM文件生成导入Windows RDP服务的pfx文件 和注册表项
#!/bin/bash
# 生成Windows导入证书所需的pfx文件
sourceKeyPath="/path/to/key"
sourceCertPath="/path/to/cert"
workDir="/outputdir"
pkcs12Password="P@ssword"
sha1=$(openssl x509 -inform PEM -in "${sourceCertPath}" -noout -fingerprint | cut -d '=' -f 2 | sed -e 's/:/,/g')
openssl pkcs12 -export -in "${sourceCertPath}" -inkey "${sourceKeyPath}" -passout "pass:${pkcs12Password}" -out "${workDir}/${uuid}/certificate.pfx" # 从PEM格式转换为
printf "Windows Registry Editor Version 5.00\r\n\r\n[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]\r\n\"SSLCertificateSHA1Hash\"=hex:${sha1}" > "${workDir}/${uuid}/certificate.reg" # 生成注册表导入文件
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment