简体   繁体   中英

Certificate java client https

I have to create a client in java that makes a https connection to a server. I have my certificate that i use with my browser to log into the web site. How can i use the same certificate on my java client? Should i add it to the Keystore?

Thank you

New information: Server and Client are both in the same host -> localhost The Client has to make a request to https:// localhost:8183 I create the user's certificate typing:

$ ./build-key fg1
$ openssl pkcs12 -export -out fg1.pfx -inkey fg1.key -in fg1.crt -certfile ca.crt -name default

then i did

$ keytool -importkeystore -srckeystore fg1.pfx -srcstoretype pkcs12 -destkeystore VEPClientRestKeyStore.jks  -srcalias default -destalias fg1 -destkeypass <mypassword>

Now i'm really lost.HOw can i use this keystore to connect to server and make requests? Thank you again.

I recently wrote a blog post , complete with examples, for doing this on Android, though the code for making the connection is the same on the desktop.

You basically have two choices - either import the certificate into a java Keystore using keytool as indicated by the post pointed to by tigran, or create the keystore in memory as needed, as in the example that accompanies my blog post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM