JAVA - 如何从sqlite db存储和读取RSA私钥

时间:2017-04-26 21:20:02

标签: java database sqlite get private-key

我将键存储为byte []到sqlite数据库。 当我想获得私钥时:

ResultSet rs  = pstmt.executeQuery();
                    while(rs.next()){                       
                        KeyFactory rsaKeyFac =  KeyFactory.getInstance("RSA");
                        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(rs.getBytes(1));
                        RSAPrivateCrtKey privKey;
                        privKey = (RSAPrivateCrtKey) rsaKeyFac.generatePrivate(keySpec);
                        result = privKey;
                }

我只得到:

sun.security.rsa.RSAPrivateCrtKeyImpl@fffd1339


我的公钥检索有效!但是使用私钥和证书我不明白。 有人可以帮忙吗?

0 个答案:

没有答案