Note: The Listed platform will permanently shut down December 31, 2026. Your data published on Listed will still be available in your personal Standard Notes account. Learn more

An error occurred (MalformedCertificate) when calling the UploadServerCertificate operation: Unknown

AWSに証明書をアップロードするときに、エラーが出た。

aws iam upload-server-certificate --server-certificate-name mycert --certificate-body file://cert.pem --private-key file://private.key --certificate-chain file://chain.pem --path /mycert/

An error occurred (MalformedCertificate) when calling the UploadServerCertificate operation: Unknown

ググると公式ドキュメントが出てくる
https://aws.amazon.com/jp/premiumsupport/knowledge-center/import-ssl-certificate-to-iam/

曰く

API リクエストのパラメータ certificate-body、certificate-chain、private-key に「file://」プレフィックスを指定する必要があります。それ以外の場合、リクエストは「MalformedCertificate:Unknown」(MalformedCertificate: 不明) というエラーメッセージで失敗します。

ちゃんとfile://プレフィックスついてるのになあ。

CLIツールのバージョン上げたが効果なし。

別のドキュメント読むと
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_server-certs.html

The private key must be unencrypted. You cannot upload a private key that is protected by a password or passphrase. For help decrypting an encrypted private key, see Troubleshooting.

なるほど、パスフレーズ付きの秘密鍵は使えないのね。前にもあったようななかったような。忘れてた。後で探せるようにブロブに書いておくために今に至る。

パスワードついてる場合は次のコマンドでパスワード無しに変換する

openssl x509 -inform DER -in Certificate.der -outform PEM -out Certificate.pem

You'll only receive email when they publish something new.

More from iwate
All posts