binarywang/WxJava · error · RuntimeException

构建 SSLContext 时发生异常!

Error message

构建 SSLContext 时发生异常!

What it means

Error "构建 SSLContext 时发生异常!" thrown in binarywang/WxJava.

Source

Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/DefaultHttpComponentsClientBuilder.java:181

  @Override
  public HttpComponentsClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) {
    this.connectionKeepAliveStrategy = keepAliveStrategy;
    return this;
  }

  private synchronized void prepare() {
    if (prepared.get()) {
      return;
    }

    SSLContext sslcontext;
    try {
      sslcontext = SSLContexts.custom()
        .loadTrustMaterial(TrustAllStrategy.INSTANCE) // 忽略对服务器端证书的校验
        .build();
    } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
      log.error("构建 SSLContext 时发生异常!", e);
      throw new RuntimeException(e);
    }

    PoolingHttpClientConnectionManager connManager = PoolingHttpClientConnectionManagerBuilder.create()
      .setTlsSocketStrategy(new DefaultClientTlsStrategy(sslcontext, NoopHostnameVerifier.INSTANCE))
      .setMaxConnTotal(this.maxTotalConn)
      .setMaxConnPerRoute(this.maxConnPerHost)
      .setDefaultSocketConfig(SocketConfig.custom()
        .setSoTimeout(this.soTimeout, TimeUnit.MILLISECONDS)
        .build())
      .setDefaultConnectionConfig(ConnectionConfig.custom()
        .setConnectTimeout(this.connectionTimeout, TimeUnit.MILLISECONDS)
        .build())
      .build();

    HttpClientBuilder httpClientBuilder = HttpClients.custom()
      .setConnectionManager(connManager)
      .setConnectionManagerShared(true)
      .setDefaultRequestConfig(RequestConfig.custom()

View on GitHub (pinned to 1c43293a3c)

Solutions

  1. 检查构造 SSLContext 所用的证书、私钥文件路径与密码是否正确,文件是否存在且可读。
  2. 确认 JDK 支持所需的 TLS 协议与算法(如 TLSv1.2),必要时升级 JDK 或安装 JCE 策略文件。

When it happens

Trigger: Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/DefaultHttpComponentsClientBuilder.java:181 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14). Data as JSON: /api/errors/2a83a0f51160afeb. Report an issue: GitHub.