0

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.

anonymez
  • 13
  • 3

1 Answers1

0

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.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67