While trying to upload ssl certificate I got below issue:
I used following command to upload ssl certificate to aws:
aws iam upload-server-certificate --server-certificate-name MysiteCertificate --certificate-body file://home/guest/Downloads/mysite/public.crt --private-key file://home/guest/Downloads/mysite/private.key --certificate-chain file://home/guest/Downloads/mysite/intermediate.pem
Output:
A client error (MalformedCertificate) occurred when calling the UploadServerCertificate operation: java.lang.ClassCastException: org.bouncycastle.openssl.PEMEncryptedKeyPair cannot be cast to org.bouncycastle.openssl.PEMKeyPair
To fix above issue first run below command:
openssl rsa -in private.key -text > private.key.new
Now try to upload ssl certificate with private.key.new instead of private.key
aws iam upload-server-certificate --server-certificate-name MysiteCertificate --certificate-body file://home/guest/Downloads/mysite/public.crt --private-key file://home/guest/Downloads/mysite/private.key.new --certificate-chain file://home/guest/Downloads/mysite/intermediate.pem