Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

Repository files navigation

gm-https

支持国密 https 的性能 servlet 容器。支持单向认证及双向认证。

有限支持 servlet 规范。

不建议用在正式环境。

项目依赖的 gmssl_provider 来自 https://gmssl.cn/gmssl官网说明:免费版本每年年底失效,程序会自动退出,需更新库,重新链接。请勿用于正式/生产环境,后果自负。

一、用法

1. client 端
@TestpublicvoidtestClient() throwsException {
Stringurl = "";
// url = "https://ebssec.boc.cn/";url = "https://localhost:4430/get1";
Map<String, String> params = newHashMap<>();
Map<String, String> headers = newHashMap<>();
params.put("ip", "192.168.1.1");
params.put("pwd", "12345678");
headers.put("token", UUID.randomUUID().toString());
Response0r2 = SSLRequests.get(url, params, headers);
System.out.println("r2.getHeader(\"app-id\") = " + r2.getHeader("app-id"));
System.out.println("r2.getContent() = " + r2.getContent());
params.put("post1", "begin--abc--end");
params.put("post2", UUID.randomUUID().toString());
url = "https://localhost:4430/post1";
SSLRequests.post(url, params, headers);
Stringjson = "{" +
"\"a\": \"abc\"," +
"\"b\": 123" +
"}";
Response0r3 = SSLRequests.post4json(url, json, headers);
System.out.println();
}
2. server 端
@TestpublicvoidtestServer() throwsException {
Stringcert = "keystore/sm2.server1.both.pfx";
cert = "sm2.auth1/sm2.auth1.both.pfx";
InputStreamin = getClass().getClassLoader().getResourceAsStream(cert);
Stringpwd = "12345678";
SSLServerserver = newSSLServer(4430, in, pwd);
server.addServlet("/get1", newTestServlet1());
server.addServlet(newTestServlet2());
// 异步server.listen();
Thread.currentThread().join();
}
3. 详细用法参考测试用例

二、maven 坐标

<groupId>cc.kkon</groupId>
<artifactId>gm-https</artifactId>
<version>0.2.1</version>

About

支持国密 https 的 servlet 容器。

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages