在调用Confidentiality Policy时,如果用到了X509证书并对传递的数据进行加密处理,会报找不到加密算法的异常,信息如下:
WSHandler: Encryption: error during message processingorg.apache.ws.security.WSSecurityException: An unsupported signature or encryption algorithm was used (unsupported key transport encryption algorithm: No such algorithm: http://www.w3.org/2001/04/xmlenc#rsa-1_5)
原因分析
JDK所带的JRE默认引入的是受限的Java Cryptography Extension(JCE)策略文件,相关jar文件对应的路径为:
<jre-home>/lib/security/local_policy.jar
<jre-home>/lib/security/US_export_policy.jar
针对不同的国家,对于JCE策略有不同的限制,在SUN网站 http://java.sun.com/javase/downloads/index.jsp#docs最底下上有详细的说明。
处理策略
1、可以下载无限制的版本并利用其对以上的两个Jar进行替换以满足要求,不过现在好像仅提供1.6版本的下载了。
2、重新选择JCE的实现,并作为provider添加
下载bouncycastle.jar (http://www.bouncycastle.org/latest_releases.html),,放到<jre_home>/lib/ext 目录下
添加security.provider,在<jre_home>/lib/security/java.security 文件进行修改添加
security.provider.7=org.bouncycastle.jce.provider.BouncyCastleProvider
3、把下载的bouncycastle.jar放到工程的classpath当中。
出处:http://gocom.primeton.com/blog15819_26284.htm