How to import a .cer certificate into a java keystore? -
during development of java webservice client ran problem. authentication webservice using client certificate, username , password. client certificate received company behind webservice in .cer
format. when inspect file using text editor, has following contents:
-----begin certificate----- [some base64 encoded data] -----end certificate-----
i can import file certificate in internet explorer (without having enter password!) , use authenticate webservice.
i able import certificate keystore first stripping first , last line, converting unix newlines , running base64-decode. resulting file can imported keystore (using keytool
command). when list entries in keystore, entry of type trustedcertentry
. because of entry type (?) cannot use certificate authenticate webservice. i'm beginning think provided certificate public certificate being used authentication...
a workaround have found import certificate in ie , export .pfx
file. file can loaded keystore , can used authenticate webservice. cannot expect clients perform these steps every time receive new certificate. load .cer
file directly java. thoughts?
additional info: company behind webservice told me certificate should requested (using ie & website) pc , user import certificate later. maybe helps...
thanks in advance,
jan-pieter
- if want authenticate need private key. there's no other option.
- a certificate public key properties (like company name, country,...) signed certificate authority guarantees attached properties true.
- .cer files certificates , don't have private key. private key provided .pfx keystore file normally. if authenticate because had imported private key.
you can import .cer certificates without problems
keytool -importcert -file certificate.cer -keystore keystore.jks -alias "alias"
Comments
Post a Comment