⚠️ 網站服務遷移公告 (System Alert)
本篇 [IIS 憑證 V5版] 文章已搬移至新站!
為了提供無廣告、更流暢的閱讀體驗,請前往新站閱讀。
🚀 點此立即前往新站閱讀
為了提供無廣告、更流暢的閱讀體驗,請前往新站閱讀。
🚀 新版發布:IIS SSL 自動化腳本 V6 (完整版)
您目前觀看的是舊版本教學。為了提升安全性與自動化穩定度,我已釋出最新的 V6 完整版,整合了 AES 加密與自動解密流程。
👉 點此前往:[PowerShell] IIS SSL 憑證自動更新全攻略 (V6)(包含完整原始碼、加密設定與排程教學)
這段程式碼的主要功能是解密之前加密過的憑證私鑰密碼,並將解密後的結果顯示在控制台上。以下是程式碼各部分的功能說明:
# 定義解密函數
function Decrypt-Password {
param (
[string]$KeyFilePath,
[string]$EncryptedPasswordFilePath
)
Write-Host "解密憑證私鑰密碼..."
$Key = [System.Convert]::FromBase64String((Get-Content $KeyFilePath))
$EncryptedPassword = Get-Content -Path $EncryptedPasswordFilePath
$SecurePassword = ConvertTo-SecureString -String $EncryptedPassword -Key $Key
$Password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword))
Write-Host "憑證私鑰密碼已成功解密: $Password" -ForegroundColor Green
}
# 解密證書私鑰密碼
Decrypt-Password -KeyFilePath $KeyFilePath -EncryptedPasswordFilePath $EncryptedPasswordFilePath
參考資料:
ChatGPT 問答測試結果