GMSSE

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

License

License

GroupId

GroupId

com.aliyun
ArtifactId

ArtifactId

gmsse
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

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

Project URL

https://github.com/aliyun/gm-jsse
Source Code Management

Source Code Management

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

Download gmsse

How to add to project

<!-- 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"]

Dependencies

compile (1)

Group / Artifact Type Version
org.bouncycastle : bcpkix-jdk15on jar 1.64

test (4)

Group / Artifact Type Version
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

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.1.0
1.0.1
1.0.0