Is it possible to convert an SSL certificate from a .key file to a .pfx?

前端 未结 4 1006
长情又很酷
长情又很酷 2020-12-01 02:58

is there a way to convert from a .key file to a .pfx file? thank you.

EDIT: I only have the .key file but my hosting provider says that I could convert it to .pfx wi

相关标签:
4条回答
  • 2020-12-01 03:39

    You could try this
    https://www.sslshopper.com/ssl-converter.html

    openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
    
    0 讨论(0)
  • 2020-12-01 03:47

    To check if your .key file has everything you need:

    #check if file contains a valid certificate:
    openssl x509 -text -in file.key
    

    It should print out certificate details. If it prints an error including the text "unable to load certificate", then your file is not sufficient.

    #check if file contains a valid key:
    openssl rsa -text -in file.key
    openssl dsa -text -in file.key
    

    One of the above commands should print out valid key details. The other will give an error with the text "expecting an rsa key" or "expecting a dsa key".

    If the error text says "bad decrypt", you have provided an invalid passphrase, or the file is damaged.

    If the error text says "Expecting: ANY PRIVATE KEY", then your file is not sufficient.

    If you got a key, and one certificate which matches the key (and optionally some other certificates), then you have enough to convert the file to a pfx. Then, as ISW said, it's just a matter of

    #convert file containing key and certificate(s) to PKCS#12 pfx file.
    openssl pkcs12 -export -out file.pfx -in file.key
    

    and you're done.

    0 讨论(0)
  • 2020-12-01 03:56

    According to the OpenSSL Command-Line HOWTO it should work using

    # export mycert.key as PKCS#12 file mycert.pfx
    openssl pkcs12 -export -out mycert.pfx -in mycert.key -name "My Certificate"
    
    0 讨论(0)
  • 2020-12-01 03:57

    You can convert your .key file to .pvk using the tool http://www.chilkatsoft.com/p/p_347.asp and then use the instructions on GoDaddy to combine both .scp and .pvk into a .pfk. Just make sure you use a password when generating the .pvk file.

    0 讨论(0)
提交回复
热议问题