找不到支持的密码套件的提供程序错误

时间:2014-12-20 03:54:17

标签: java ssl encryption java-8

“TLS_RSA_WITH_AES_128_CBC_SHA256”密码套件由java 8默认提供程序支持。参考 - https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJSSEProvider

我也有以下程序来验证。 但是当我试图获得相同算法的密码时,它会产生错误。

import java.security.NoSuchAlgorithmException;

import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;

public class CipherSuitesInfoGenerator {

  public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException {

    SSLContext context = SSLContext.getDefault();
    SSLSocketFactory sf = context.getSocketFactory();
    String[] cipherSuites = sf.getSupportedCipherSuites();

    String cipherName = "TLS_RSA_WITH_AES_128_CBC_SHA256";

    for (String s : cipherSuites) {
      if (s.equals(cipherName)) {
        System.out.println(cipherName + " is supported");

        try {
          Cipher cipher = Cipher.getInstance(cipherName);
        } catch (Exception e) {
          System.out.println(e.getMessage());
        }

        break;
      }

    }
  }
}

输出结果为:

TLS_RSA_WITH_AES_128_CBC_SHA256 is supported
Cannot find any provider supporting TLS_RSA_WITH_AES_128_CBC_SHA256

1 个答案:

答案 0 :(得分:3)

密码套件是在JSSE提供程序内部使用的东西,它定义了TLS协议中使用的原语。它不是Cipher,Java中的Cipher实例代表一个用于加密/解密的原语,如AES或RSA。