Peter
Peter

Reputation: 333

How to convert a PublicKey to JSON in Java?

I want to send a client's public key (java.security.publickey) in JSON format to my server. I'm using Google's Gson library to convert in between, however, I'm getting a runtime exception which tells me that Key is an interface and I need some kind of adapter to parse it. Have anyone encountered this problem? Any solution is welcome, I just need to transfer the key via HTTP.

Thank you!

Upvotes: 0

Views: 1844

Answers (1)

Bart
Bart

Reputation: 226

You can get the encoded key using the getEncoded() method and send that via JSON to your server.

Upvotes: 3

Related Questions