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

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s