You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

绑定Let's Encrypt证书到Azure App Service时遇密码错误问题

问题:Azure App Service绑定Let's Encrypt SSL证书提示密码错误

尝试将已创建的Let's Encrypt SSL证书绑定到Azure App Service,应用服务的DNS已配置为1.test.webapp1,执行以下PowerShell命令时遇到错误:

$Site = Get-AzWebApp -ResourceGroupName "MyRG" -Name "webapp1"

New-AzWebAppSSLBinding `
    -Name "1.test.webapp1" `
    -WebApp $Site `
    -SslState SniEnabled `
    -CertificateFilePath "C:\Users\someuser\Downloads\*.test.webapp1.pfx" `
    -CertificatePassword 'password' 

错误提示:New-AzWebAppSSLBinding - 指定的网络密码不正确

补充信息:证书生成输出

Subject       : CN=*.test.webapp1
NotBefore     : 
NotAfter      : 
KeyLength     : 2048
Thumbprint    : 
AllSANs       : {*.test.webapp1}
CertFile      : C:website\cert.cer
KeyFile       : C:website\cert.key
ChainFile     : C:website\chain.cer
FullChainFile : C:website\fullchain.cer
PfxFile       : C:website\cert.pfx
PfxFullChain  : C:website\fullchain.pfx
PfxPass       : System.Security.SecureString

解决方法

问题出在密码类型不匹配:生成的证书密码是System.Security.SecureString类型,但你传入的是明文字符串,导致验证失败。按以下步骤修正:

  1. 将明文密码转换为SecureString类型
    先定义SecureString类型的密码变量:

    $securePassword = ConvertTo-SecureString "你的实际证书密码" -AsPlainText -Force
    
  2. 修改SSL绑定命令
    把-CertificatePassword参数替换为上面定义的$securePassword,修正后的完整命令:

    $Site = Get-AzWebApp -ResourceGroupName "MyRG" -Name "webapp1"
    $securePassword = ConvertTo-SecureString "你的实际证书密码" -AsPlainText -Force
    
    New-AzWebAppSSLBinding `
        -Name "1.test.webapp1" `
        -WebApp $Site `
        -SslState SniEnabled `
        -CertificateFilePath "C:\Users\someuser\Downloads\*.test.webapp1.pfx" `
        -CertificatePassword $securePassword
    

额外检查项

  • 确认输入的密码和生成PFX证书时设置的完全一致,Let's Encrypt工具生成PFX时会指定密码,务必核对准确。
  • 可以先在本地用证书导入向导测试PFX文件和密码是否有效:双击PFX文件,输入密码如果能正常导入,说明密码和文件都没问题。
  • 确保命令中指定的PFX文件路径正确,避免因路径错误读取到无效文件。

内容的提问来源于stack exchange,提问作者Kraken194

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 08:54:19