java.security.NoSuchAlgorithmException: RSA Signature not available

前端 未结 4 2025
南旧
南旧 2021-02-09 06:06

this is exception

Exception in thread \"main\" java.security.NoSuchAlgorithmException: RSA Signature not available
    at java.security.Signature.getInstance(Signatu         


        
4条回答
  •  长情又很酷
    2021-02-09 06:30

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

    TreeSet 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?

提交回复
热议问题