PDF 加密报错No installed provider supports this key: sun.security.rsa.RSAPublicKeyImpl

运行iText 官方例子Certificate encryption 报以下错误
Exception in thread "main" ExceptionConverter: java.security.InvalidKeyException: No installed provider supports this key: sun.security.rsa.RSAPublicKeyImpl
at javax.crypto.Cipher.chooseProvider(Cipher.java:878)
at javax.crypto.Cipher.init(Cipher.java:1213)
at javax.crypto.Cipher.init(Cipher.java:1153)
at com.itextpdf.text.pdf.PdfPublicKeySecurityHandler.computeRecipientInfo(PdfPublicKeySecurityHandler.java:272)
at com.itextpdf.text.pdf.PdfPublicKeySecurityHandler.createDERForRecipient(PdfPublicKeySecurityHandler.java:244)
at com.itextpdf.text.pdf.PdfPublicKeySecurityHandler.getEncodedRecipient(PdfPublicKeySecurityHandler.java:193)
at com.itextpdf.text.pdf.PdfEncryption.getEncryptionDictionary(PdfEncryption.java:664)
at com.itextpdf.text.pdf.PdfWriter.setEncryption(PdfWriter.java:2159)
at com.js.pdf.security.EncryptWithCertificate.createPdf(EncryptWithCertificate.java:55)
at com.js.pdf.security.EncryptWithCertificate.main(EncryptWithCertificate.java:41)

解决方法:
下载Java Cryptography Extension
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html(这个是Java 1.7的)
找到你的java 安装路径
将文件附加到%java-home%\jer\lib\security 文件夹下
参考文档
http://blog.csdn.net/yangtao6888/article/details/7733029

你可能感兴趣的:(java,iTest,pdf,错误)