• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Store PrivateKey PublicKey in DB

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to store PrivateKey and PublicKey objects in a MySQL database. From an example in another post here at the forum:
https://coderanch.com/t/134195/Security/store-PublicKey-PrivateKey-database

The code example from that posts are:

Use the getEncoded() method to get the byte[] from the keys. To go the other way, getting an RSAPublicKey or RSAPrivateKey from a byte[], use the appropriate KeyFactory methods and encoded key specs, e.g. for RSAPrivateKey



and for RSAPublicKey


I succeed in storing and retreiving the private key as in the first example. But when I try the public key conversion from byte array to a PublicKey object I get the following exception:



Somebody have a clue why the PublicKey example does not work?

Best regards

Lasse
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot be sure without looking at the file in question. I would have to guess that the encoded public key is not in the correct format or has simply been retrieved incorrectly.
 
reply
    Bookmark Topic Watch Topic
  • New Topic