GMSSE

Aliyun GMSSE for Java Copyright (C) Alibaba Cloud Computing All rights reserved. 版权所有 (C)阿里云计算有限公司 http://www.aliyun.com

Лицензия

Лицензия

Группа

Группа

com.aliyun
Идентификатор

Идентификатор

gmsse
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

GMSSE
Aliyun GMSSE for Java Copyright (C) Alibaba Cloud Computing All rights reserved. 版权所有 (C)阿里云计算有限公司 http://www.aliyun.com
Ссылка на сайт

Ссылка на сайт

https://github.com/aliyun/gm-jsse
Система контроля версий

Система контроля версий

https://github.com/aliyun/gm-jsse

Скачать gmsse

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.aliyun/gmsse/ -->
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>gmsse</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.aliyun/gmsse/
implementation 'com.aliyun:gmsse:1.1.0'
// https://jarcasting.com/artifacts/com.aliyun/gmsse/
implementation ("com.aliyun:gmsse:1.1.0")
'com.aliyun:gmsse:jar:1.1.0'
<dependency org="com.aliyun" name="gmsse" rev="1.1.0">
  <artifact name="gmsse" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.aliyun', module='gmsse', version='1.1.0')
)
libraryDependencies += "com.aliyun" % "gmsse" % "1.1.0"
[com.aliyun/gmsse "1.1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.bouncycastle : bcpkix-jdk15on jar 1.64

test (4)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.13.1
org.mockito : mockito-core jar 2.23.4
org.powermock : powermock-api-mockito2 jar 2.0.5
org.powermock : powermock-module-junit4 jar 2.0.5

Модули Проекта

Данный проект не имеет модулей.

English | 简体中文

GM JSSE

Latest Stable Version

Requirements

  • JDK 1.7 or later.

Installation

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>gmsse</artifactId>
    <version>{{see the version on the badge}}</version>
</dependency>

Usage

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import java.net.URL;

import com.aliyun.gmsse.GMProvider;

public class Main {

    public static void main(String[] args) throws Exception {
        // init SSLSocketFactory
        GMProvider provider = new GMProvider();
        SSLContext sc = SSLContext.getInstance("TLS", provider);
        sc.init(null, null, null);
        SSLSocketFactory ssf = sc.getSocketFactory();

        URL serverUrl = new URL("https://xxx/");
        HttpsURLConnection conn = (HttpsURLConnection) serverUrl.openConnection();
        conn.setRequestMethod("GET");
        // set SSLSocketFactory
        conn.setSSLSocketFactory(ssf);
        conn.connect();
        System.out.println("used cipher suite:");
        System.out.println(conn.getCipherSuite());
    }
}

In the new version, GM-JSSE will verify server and CA certificates, if the CA root certificates are not imported in system, maybe have verfication errors. So you need add trust manager with CA certificates.

    BouncyCastleProvider bc = new BouncyCastleProvider();
    KeyStore ks = KeyStore.getInstance("JKS");
    CertificateFactory cf = CertificateFactory.getInstance("X.509", bc);
    FileInputStream is = new FileInputStream("/path/to/ca_cert");
    X509Certificate cert = (X509Certificate) cf.generateCertificate(is);
    ks.load(null, null);
    ks.setCertificateEntry("gmca", cert);

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509", provider);
    tmf.init(ks);

    sc.init(null, tmf.getTrustManagers(), null);
    SSLSocketFactory ssf = sc.getSocketFactory();

Issues

Opening an Issue, Issues not conforming to the guidelines may be closed immediately.

Changelog

Detailed changes for each release are documented in the release notes.

License

Apache-2.0

Copyright (c) 2009-present, Alibaba Cloud All rights reserved.

com.aliyun

Alibaba Cloud

More Than Just Cloud

Версии библиотеки

Версия
1.1.0
1.0.1
1.0.0