java rsa加密报java.security.InvalidKeyException: IOException : algid parse error, not a sequence

java rsa 加密报这个异常,应该秘钥的问题,: rsa 秘钥不是pks8 格式

Caused by: java.security.InvalidKeyException: IOException : algid parse error, not a sequence

at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:351)
at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:356)
at sun.security.rsa.RSAPrivateCrtKeyImpl.(RSAPrivateCrtKeyImpl.java:91)
at sun.security.rsa.RSAPrivateCrtKeyImpl.newKey(RSAPrivateCrtKeyImpl.java:75)
at sun.security.rsa.RSAKeyFactory.generatePrivate(RSAKeyFactory.java:316)
at sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:213)

... 4 more

我的秘钥是别人给的,用openssl生成的rsa密钥对,openssl 会先生成一个.key文件,然后根据这个来生成公钥和私钥,但是被一个不懂的人给坑了,一直给我的.key文件的值,一直说是对的,如果你的java程序没问题,但是却一直报这个异常,很大的可能是秘钥的问题

你可能感兴趣的:(java,exception)