

Use a p12 certificate with Web Services / SSL in Java and CXF
source link: https://marco.dev/2013/06/30/use-p12-certificate-with-web-services-in-java-and-cxf/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

java-version.com: What's new in Java 16? 15? Keep up to date!
Use a p12 certificate with Web Services / SSL in Java and CXF
Problem : I need to access a webservice of a provider. The provider gave to me a .cert file and a .p12 file.
The private key p12 is not easy to manage in java. The default Key Store (cacert) doesn’t manage private keys.
I’m using apache cxf to access the webservice.
Solution:
- Create a new Key Store for your private key and import the p12 file
keytool -importkeystore -srckeystore privateKeyFile.p12 -srcstoretype PKCS12 -destkeystore personalKeyStore.jks
The .cert file should be imported in the cacert file:
https://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/keytool.html
You can easily access the certificate and the personal key from cxf using the following configuration.
For the private.jks store you need two passwords:
One password to access the file private.jks: ‘storePassword’
One password to access the private key inside the private.jks: ‘personalKeyPassword’ the provider gave to you this password.
Author
Marco Molteni
Marco Molteni Blog
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK