【问题标题】:Cannot find provider error for the supported cipher suite找不到受支持密码套件的提供程序错误
【发布时间】:2014-12-20 03:54:17
【问题描述】:

java 8 默认提供程序支持“TLS_RSA_WITH_AES_128_CBC_SHA256”密码套件。参考 - 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

【问题讨论】:

  • 这可能是一个愚蠢的问题,但你确定你在 Java 8 上运行你的代码吗?
  • 是的。我相信。我认为这个程序按预期工作。但现在它给出了错误。我不知道开发环境是否发生了变化。我已按原样复制粘贴的代码和输出。
  • 密码套件!=密码。它们不是一回事。

标签: java ssl encryption java-8


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-14
    • 2021-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多