Bluemix RSA Private key cannot be used to encrypt
来源:互联网 发布:爱数据网课程 编辑:程序博客网 时间:2024/06/06 03:58
前言:
如果我们使用IBM的JDK,然后采用私钥进行RSA加密,就可能报错,如下:
java.security.InvalidKeyException: Private key cannot be used to encrypt. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614) at java.lang.Thread.run(Thread.java:777) at com.ibm.crypto.provider.RSASSL.engineInit(Unknown Source) at javax.crypto.Cipher.init(Unknown Source) at javax.crypto.Cipher.init(Unknown Source) at java.security.Signature$CipherAdapter.engineInitSign(Signature.java:1239) at java.security.Signature$Delegate.init(Signature.java:1116) at java.security.Signature$Delegate.chooseProvider(Signature.java:1076) at java.security.Signature$Delegate.engineInitSign(Signature.java:1140) at java.security.Signature.initSign(Signature.java:522) at net.vx4.lib.tls.core.TLSSignature.createSignature(TLSSignature.java:120)看到这个错误,我们很好理解,就是私钥不能用于RAS加密:
Private key cannot be used to encrypt.其实IBM JDK这么做也是有道理的,如果我们采用公钥加密,那么只有拥有私钥的人,才能解密,这样信息是绝对安全的。可是如果我们用私钥加密,那么任何拥有公钥的人,都能解密,这样信息是不安全的。不过有时候也需要这么做,因为可以保证消息的可靠性。
所以默认情况下,IBM JDK这么做,也是完全可以理解的。那我们需要采用私钥加密,那要怎么办?
只需要添加这个属性就可以了:-Dcom.ibm.crypto.provider.DoRSATypeChecking=false
那么如何在Bluemix上解决这个问题,好吧,CF又来了,又是2行命令,修改环境变量:
cf set-env [Your App's Name] IBM_JAVA_OPTIONS "-Dcom.ibm.crypto.provider.DoRSATypeChecking=false"
cf restage [Your App's Name]
执行成功以后,在Bluemix官网中,就能看到“环境变量”里的“用户自定义”里看到刚才设置的环境变量,上上篇的博客里已经提到了,这里不再啰嗦。 0 0
- Bluemix RSA Private key cannot be used to encrypt
- AddFieldAsXml cannot be used to set the InternalName correctly
- openssl_sign(): supplied key param cannot be coerced into a private key
- RSA ENCRYPT
- ColorAnimation cannot be used to animate property Background due to incompatible type
- RSA private key file not found
- RSA private key file not found
- a build only device cannot be used to run this targe
- build only device cannot be used to run this target问题
- A build only device cannot be used to run this target.
- appium Activity used to start app doesn't exist or cannot be launched 问题解决
- A build only device cannot be used to run this target.----献给新手
- ios a build only device cannot be used to run this target
- A build only device cannot be used to run this target.
- Appium Desktop-启动异常Activity used to start app doesn't exist or cannot be launched!
- tail: inotify resources exhausted tail: inotify cannot be used, reverting to polling
- cannot be used as a boolean
- CashCard expired and cannot be used
- 从工程中删除Cocoapods
- Comparable与Comparator的区别
- 0.11版linux文件系统(二)
- CF 557B Pasha and Tea
- JavaScript基本语法(第一
- Bluemix RSA Private key cannot be used to encrypt
- 如何取消edittext进入就获得焦点
- Android工程师面试题大全
- JDBC事务
- 0.11版linux文件系统(一)
- 编写一个Java程序,在程序中包含一个Employee类,Employee类包含name、age、salary三个成员变量
- ARC 学习笔记(二)-Outlet与弱引用
- LeetCode----Swap Nodes in Pairs
- ——黑马程序员——C语言基础--进制转换问题