欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

狗日的支付宝

程序员文章站 2022-07-04 16:44:00
...

 

用openssl 生成的密钥老是报以下错误:

java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException : DER input, Integer tag error
	at sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:200)
	at java.security.KeyFactory.generatePrivate(KeyFactory.java:342)
	at com.qhx.component.payment.payplatform.alipay.util.RSASignature.getPrivateKey(RSASignature.java:84)
	at com.qhx.component.payment.payplatform.alipay.util.RSASignature.main(RSASignature.java:161)
Caused by: java.security.InvalidKeyException: IOException : DER input, Integer tag error
	at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:344)
	at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:350)
	at sun.security.rsa.RSAPrivateCrtKeyImpl.<init>(RSAPrivateCrtKeyImpl.java:74)
	at sun.security.rsa.RSAPrivateCrtKeyImpl.newKey(RSAPrivateCrtKeyImpl.java:58)
	at sun.security.rsa.RSAKeyFactory.generatePrivate(RSAKeyFactory.java:299)
	at sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:196)
	... 3 more

后来发现,原来是支付宝,生成的命令有问题,参数放错位置,害死人。

 


狗日的支付宝
            
    
    博客分类: JAVA RSA 
 

 

 将(3) 的命令改为:

openssl pkcs8 -topk8 -nocrypt -inform PEM -in rsa_private_key.pem -outform PEM outform

 

完整命令:

1.

openssl genrsa -out rsa_private_key.pem 1024

2.

openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem 

 

3.openssl pkcs8 -topk8 -nocrypt -inform PEM -in rsa_private_key.pem -outform PEM outform

 

 

 

  • 狗日的支付宝
            
    
    博客分类: JAVA RSA 
  • 大小: 78.1 KB
相关标签: RSA