且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

java.security.NoSuchAlgorithmException:RSA 签名不可用

更新时间:2022-10-19 15:58:31

If you run the following code, you will get a list of signature algorithms supported by your Java installation.

TreeSet<String> algorithms = new TreeSet<>();
for (Provider provider : Security.getProviders())
    for (Service service : provider.getServices())
        if (service.getType().equals("Signature"))
            algorithms.add(service.getAlgorithm());
for (String algorithm : algorithms)
    System.out.println(algorithm);

When I run it (Windows, Java 1.8.0_65), I get:

MD2withRSA
MD5andSHA1withRSA
MD5withRSA
NONEwithDSA
NONEwithECDSA
NONEwithRSA
SHA1withDSA
SHA1withECDSA
SHA1withRSA
SHA224withDSA
SHA224withECDSA
SHA224withRSA
SHA256withDSA
SHA256withECDSA
SHA256withRSA
SHA384withECDSA
SHA384withRSA
SHA512withECDSA
SHA512withRSA

As you can see, RSA is not a valid signature algorithm.
Maybe NONEwithRSA is what you're after?