简体   繁体   English

创建自签名证书并将其上传到 Azure 应用服务的最简单方法

[英]Easiest way to create and upload a self-signed certificate to Azure App Service

I'm looking for some CLI commands or a script of some sort that I can execute to do the following in one step我正在寻找一些 CLI 命令或某种类型的脚本,我可以执行这些命令以一步完成以下操作

  1. create a self-signed certificate创建自签名证书
  2. upload it to my Azure App Service上传到我的 Azure 应用服务
  3. create an app setting param with the certificate thumbprint as value使用证书指纹作为值创建应用程序设置参数

Has anyone done this before?有没有人这样做过?

1. Create a self-signed certificate 1. 创建自签名证书

If you want to create a self-signed certificate, we can use OpenSSL to implement it.如果要创建自签名证书,我们可以使用OpenSSL来实现。 For more details, please refer to here and here有关更多详细信息,请参阅此处此处

a.一个。 Create the certificate key and the signing (csr).创建证书密钥和签名 (csr)。

openssl req -new -x509 \
            -newkey rsa:2048 \            
            -sha256 \
            -days 3650 \
            -nodes \
            -out example.crt \
            -keyout example.key \
            -subj "/C=SI/ST=Ljubljana/L=Ljubljana/O=Security/OU=IT Department/CN=www.example.com"

The fields, specified in -subj line are listed below:下面列出了在-subj行中指定的字段:

  • C= - Country name. C= - 国家名称。 The two-letter ISO abbreviation.两个字母的 ISO 缩写。
  • ST= - State or Province name. ST= - State 或省名。
  • L= - Locality Name. L= - 地区名称。 The name of the city where you are located.您所在城市的名称。
  • O= - The full name of your organization. O= - 您的组织的全名。
  • OU= - Organizational Unit. OU= - 组织单位。
  • CN= - The fully qualified domain name CN= - 完全限定域名

b.湾。 Generate the certificate生成证书

openssl pkcs12 \
            -inkey example.key \
            -in example.crt \
            -export -out example.pfx \
            -password pass:<your password>

2. Upload it to my Azure App Service and save the certificate thumbprint in Azure App service app settings 2. 上传到我的 Azure App Service 并将证书指纹保存在 Azure App service app settings 中

Regarding the issue, please refer to the following code关于这个问题,请参考以下代码

az login

# Upload the SSL certificate and get the thumbprint.
thumbprint=$(az webapp config ssl upload --certificate-file $pfxPath \
--certificate-password $pfxPassword --name $webappname --resource-group $resourceGroup \
--query thumbprint --output tsv)

# save thumbprint 
az webapp config appsettings set --name $appName --resource-group myResourceGroup \
  --settings "Certificate _Thumbprint=$thumbprint"

在此处输入图像描述 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用自签名证书的Azure应用服务 - Azure App Service using Self-Signed Cert 将自签名CA证书安装到Azure - Install Self-Signed CA Certificate to Azure Key Vault 上的 Azure 自签名证书 - Azure self-signed certificate on Key vault 我是否可以仅使用makecert.exe为Windows Azure创建自签名SSL证书? - Can I create a self-signed SSL certificate for Windows Azure using only makecert.exe? 我可以在实时 Azure 云上使用自签名证书吗? - Can I use a self-signed certificate on a live Azure cloud? 为 Azure Web App 创建证书链(自签名) - create a certificate chain (Self Signed) for Azure Web App 使用自签名SSL证书的Azure Web App调用本地服务 - Azure Web App calling on-prem service with Self-Signed SSL Cert 如何使用自签名证书通过Azure管理库进行身份验证? - How to use self-signed certificate to authenticate using Azure Management Library? Azure 数据工厂 v2 - Web 活动 - 向 HTTPS 自签名证书提交请求 - Azure Data Factory v2 - Web Activity - Post Request to HTTPS self-signed Certificate 安全错误,在Azure(Asp.net核心)上发布带有客户端证书(自签名根)的邮件 - Security Error, post with Client Certificate (Self-signed Root) on Azure (Asp.net core)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM