Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ocadaruma/jktls
Kernel TLS on Java
https://github.com/ocadaruma/jktls
Last synced: about 2 months ago
JSON representation
Kernel TLS on Java
- Host: GitHub
- URL: https://github.com/ocadaruma/jktls
- Owner: ocadaruma
- License: apache-2.0
- Created: 2022-06-09T08:06:49.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-06-14T02:34:29.000Z (over 2 years ago)
- Last Synced: 2023-08-14T21:50:30.776Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 119 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jktls
[![CI](https://github.com/ocadaruma/jktls/actions/workflows/ci.yml/badge.svg)](https://github.com/ocadaruma/jktls/actions/workflows/ci.yml)
[Kernel TLS](https://docs.kernel.org/networking/tls.html) on Java.
> **Warning**
> The project is still in experimental phase. DO NOT USE IN PRODUCTION## Overview
Kernel TLS (kTLS), which is introduced in Linux 4.13 is a mechanism to offload TLS symmetric crypto processing to the kernel.
In a nutshell, kTLS works like below:
- Establish the TCP connection between client and server as usual
- Begin the TLS handshake as usual
- Once the handshake has finished, pass crypto information from the application to the kernel via `setsockopt`
- After that, kernel offloads symmetric crypto processing for data exchange`jktls` provides Java API to enable kTLS on sockets.
Currently, tested only on following platforms.
- JDK: 8, 11
- OS: linux
- Architecture: x86_64## Setup
Add following line to your build.gradle:
```
implementation "com.mayreh.jktls:jktls:LATEST_VERSION"
```Also, you need to load `tls` kernel module.
```
$ sudo modprobe tls
```
## UsageAs soon as TLS handshake has finished, you need to extract crypto information from `SSLEngine`
and configure the socket options as well.```java
KTlsSocketChannel ch = KTlsSocketChannel.wrap(socketChannel);
TlsCryptoInfo info = TlsCryptoInfo.from(engine);// Enable TLS upper layer protocol
ch.setOption(KTlsSocketOptions.TCP_ULP, "tls");// Enable TLS Data transmission offload
ch.setOption(KTlsSocketOptions.TLS_TX, info);
```See `KTlsServer` in `testing` module for detailed example.