0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure AppServiceで証明書をpythonで取得する

Last updated at Posted at 2024-11-29

公式ドキュメントではC#しかなかったので備忘もかねて書きます
https://learn.microsoft.com/ja-jp/azure/app-service/configure-ssl-certificate-in-code?tabs=windows

hoge.py
from cryptography.hazmat.primitives.serialization import pkcs12
#証明書は以下のディレクトリにある。該当のAppsevice or FunctionsにSSHして確認
p12_file = "/var/ssl/private/yourthumorint.p12"
    #Appservice証明書を使用している場合、Passwordは空なので以下のように記述
    pw = b""

    try:
        with open(p12_file, 'rb') as f:
            p12_data = f.read()
            # Load the PKCS12 file
            private_key, certificate, additional_certificates = pkcs12.load_key_and_certificates(p12_data,pw)
            print(certificate.subject)
    except Exception as e:
            print(e)
            certificate = "failed to find certificate"

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?