Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
8b722f1
chore: add multiplatform build
luohf-infinilabs Feb 6, 2026
715e498
chore: update platform label
luohf-infinilabs Feb 6, 2026
2255d4b
fix: update platform label
luohf-infinilabs Feb 6, 2026
8ece00d
Merge pull request #1 from infinilabs/multiplatform
luohoufu Feb 6, 2026
f90372b
chore: update platform lable
luohf-infinilabs Feb 6, 2026
3b47ff5
chore: update platform lable (#2)
luohoufu Feb 6, 2026
28c12e2
fix: update platform lable
luohf-infinilabs Feb 6, 2026
107778e
fix: release run on platform (#3)
luohoufu Feb 6, 2026
73866c0
fix: update platform lable with ubuntu 24.04
luohf-infinilabs Feb 6, 2026
e42e760
Merge branch 'master' into multiplatform
luohoufu Feb 6, 2026
1d32ec0
Multiplatform (#4)
luohoufu Feb 6, 2026
61c7588
fix: build errror on arm64
luohf-infinilabs Feb 6, 2026
7c6457b
fix: arm64 build error (#5)
luohoufu Feb 6, 2026
a7184da
chore: update lable for platform (#6)
luohoufu Feb 6, 2026
8a80aec
chore: add VC-WIN64-ARM for build
luohf-infinilabs Feb 6, 2026
531b3a2
Merge branch 'master' into multiplatform
luohoufu Feb 6, 2026
37a9589
chore: add VC-WIN64-ARM for windows (#7)
luohoufu Feb 6, 2026
85de61e
chore: update the releease actions check jar (#8)
luohoufu Feb 6, 2026
c149e1f
chore: add check for jar file
luohf-infinilabs Feb 6, 2026
04767d1
chore: add the info and stack for build
luohf-infinilabs Feb 9, 2026
02bfab8
chore: add the gradle build info (#9)
luohoufu Feb 9, 2026
9684f32
chore: update the job
luohf-infinilabs Feb 9, 2026
78f0e62
chore: refactor the ci build
luohf-infinilabs Feb 9, 2026
58bd739
fix: upload 409 error
luohf-infinilabs Feb 9, 2026
dc81d42
chore: add permission for build
luohf-infinilabs Feb 9, 2026
0d4beb0
chore: add permission for build
luohf-infinilabs Feb 9, 2026
f6f2aa0
fix: the ci target
luohf-infinilabs Feb 9, 2026
8fdd501
fix: windows platform build
luohf-infinilabs Feb 9, 2026
0ea688e
fix: gh archive download failture
luohf-infinilabs Feb 9, 2026
664467b
Merge branch 'master' into multiplatform
luohoufu Feb 9, 2026
7817f59
fix: the ci permission (#10)
luohoufu Feb 9, 2026
56186d2
chore: update the step name
luohf-infinilabs Feb 9, 2026
ef6a2ff
fix: windows arm64 build
luohf-infinilabs Feb 9, 2026
ade2238
Merge branch 'master' into multiplatform
luohoufu Feb 9, 2026
213aba0
chore: add windows arm64 build (#11)
luohoufu Feb 9, 2026
5727f3e
chore: use deafult gradle download url
luohf-infinilabs Feb 9, 2026
8bef973
chore: update the ci actions version
luohf-infinilabs Feb 9, 2026
476c31c
chore: update check step for cross compile
luohf-infinilabs Feb 9, 2026
38ca6ae
chore: use qemu for macos x86_64
luohf-infinilabs Feb 9, 2026
eda4a27
fix: windows arm64 and macos x86_64
luohf-infinilabs Feb 9, 2026
cef0450
Merge branch 'master' into multiplatform
luohoufu Feb 9, 2026
6a01054
fix: macos x86_64 and windows arm64 (#12)
luohoufu Feb 9, 2026
4e3bd80
fix: release build for windows dynamic
luohf-infinilabs Feb 9, 2026
26ce133
fix: use ubuntu for windows arm64 cross build
luohf-infinilabs Feb 9, 2026
aa2dfa6
Merge branch 'master' into multiplatform
luohoufu Feb 9, 2026
6c8a046
chore: update the windows arm64 build with ubuntu (#13)
luohoufu Feb 9, 2026
d506654
fix: ci set up error
luohf-infinilabs Feb 9, 2026
5732d48
chore: update the ci and release for arm64 build
luohf-infinilabs Feb 9, 2026
0e97aab
chore: typo the darwin
luohf-infinilabs Feb 9, 2026
4751510
chore: revert change for darwin
luohf-infinilabs Feb 9, 2026
6897a95
chore: update the windows arm64 build
luohf-infinilabs Feb 9, 2026
003767f
fix: update the windows arm64 build
luohf-infinilabs Feb 9, 2026
4cb8896
fix: windows build error
luohf-infinilabs Feb 9, 2026
cc46158
fix: resource comiler error
luohf-infinilabs Feb 9, 2026
ea57108
fix: windows arm64 build
luohf-infinilabs Feb 9, 2026
114cde0
fix: windows arm64 build with config
luohf-infinilabs Feb 9, 2026
d644eb0
fix: windows arm64 build
luohf-infinilabs Feb 9, 2026
0601aee
fix: windows arm64 build dynamic
luohf-infinilabs Feb 9, 2026
9bff12c
fix: macos arm64 build
luohf-infinilabs Feb 9, 2026
3bc4be2
fix: windows arm64 check
luohf-infinilabs Feb 9, 2026
c54db76
fix: gradle check
luohf-infinilabs Feb 9, 2026
6b4c337
fix: make error
luohf-infinilabs Feb 9, 2026
a6fb250
fix: make error windows arm64
luohf-infinilabs Feb 9, 2026
4a03e01
fix: make error windows arm64 and macos arm64
luohf-infinilabs Feb 9, 2026
08a7734
fix: make error windows arm64 and macos arm64
luohf-infinilabs Feb 9, 2026
6f4f545
Merge branch 'master' into multiplatform
luohoufu Feb 9, 2026
cfa73d7
fix: make error windows arm64 and macos arm64
luohf-infinilabs Feb 9, 2026
7bb813b
fix: make error windows arm64 and macos arm64
luohf-infinilabs Feb 9, 2026
1b207a7
fix: make error windows arm64 and macos arm64
luohf-infinilabs Feb 9, 2026
77ab225
fix: make error windows arm64 and macos arm64
luohf-infinilabs Feb 9, 2026
e3453ee
fix: make error windows arm64 and macos arm64
luohf-infinilabs Feb 9, 2026
6071b15
fix: make error windows gredle check path
luohf-infinilabs Feb 9, 2026
b27acfe
fix: make error windows gredle check path
luohf-infinilabs Feb 9, 2026
42abff1
fix: make error windows gredle check path
luohf-infinilabs Feb 9, 2026
42ffd2d
fix: windows arm64 not support
luohf-infinilabs Feb 10, 2026
cad4946
fix: windows arm64 not support
luohf-infinilabs Feb 10, 2026
3275a91
fix: windows arm64 not support
luohf-infinilabs Feb 10, 2026
59452ab
chore: ci and release process success
luohoufu Feb 10, 2026
dc8c757
fix: uber jar for release
luohf-infinilabs Feb 10, 2026
a28ba24
chore: reelase uber jar (#15)
luohoufu Feb 10, 2026
c9b81c2
chore: add static uber jar build
luohf-infinilabs Feb 10, 2026
24a20e1
Merge branch 'master' into multiplatform
luohoufu Feb 10, 2026
0a09502
chore: build static uber jar (#16)
luohoufu Feb 10, 2026
93498c3
chore: update test example for uber jar
luohf-infinilabs Feb 10, 2026
84ec968
chore: add test scripts
luohf-infinilabs Feb 10, 2026
aba815e
chore: change example for tests (#17)
luohoufu Feb 10, 2026
6945c31
Fix dynamic uber JAR: bundle Tongsuo libraries and add manifest info
luohf-infinilabs Feb 10, 2026
6c03ed2
chore: update dynamic jar rpath (#18)
luohoufu Feb 10, 2026
a3ba77f
Fix: detect dynamic build by checking for Tongsuo shared libs
luohf-infinilabs Feb 10, 2026
e9f8ef1
Merge branch 'master' into multiplatform
luohoufu Feb 10, 2026
0c4f28f
chore: build type with ci task (#19)
luohoufu Feb 10, 2026
1cf56ee
Fix: remove duplicate tongsuoHome variable definition
luohf-infinilabs Feb 10, 2026
894231b
Fix: use regular tasks instead of Exec for rpath fixing
luohf-infinilabs Feb 10, 2026
bc2dabd
fix: build error with change gradle (#20)
luohoufu Feb 10, 2026
ceeae7f
Add Git and version info to uber JAR manifests
luohf-infinilabs Feb 10, 2026
04eb8a2
Revert Tongsuo library bundling - dynamic JARs now require system Ton…
luohf-infinilabs Feb 10, 2026
9eacfda
Merge branch 'master' into multiplatform
luohoufu Feb 10, 2026
883ddfe
chore: revert the dynamic uber (#21)
luohoufu Feb 10, 2026
d370140
Fix YAML syntax error in release workflow
luohf-infinilabs Feb 10, 2026
a7779b6
Fix YAML: use single heredoc with double quotes for MANIFEST
luohf-infinilabs Feb 10, 2026
b1cd93c
Replace heredoc with echo commands to avoid YAML syntax issues
luohf-infinilabs Feb 10, 2026
88e8daf
Merge branch 'master' into multiplatform
luohoufu Feb 10, 2026
55dff44
Enhance release notes with detailed documentation
luohf-infinilabs Feb 10, 2026
2b5701b
Change Maven Group ID from net.tongsuo to com.infinilabs
luohf-infinilabs Feb 10, 2026
4c3f1c2
Add configurable Maven publishing for forks
luohf-infinilabs Feb 10, 2026
afce027
Revert publishing configuration changes
luohf-infinilabs Feb 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
855 changes: 732 additions & 123 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

1,571 changes: 1,432 additions & 139 deletions .github/workflows/release.yml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ subprojects {
}
}
}
gcc(Gcc)
gcc(Gcc){
target("linux_aarch64") {
cppCompiler.executable = "/usr/bin/gcc"
}
}
}
}
}
Expand Down
198 changes: 186 additions & 12 deletions examples/jce/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,207 @@
# JCE Examples

Every example in this directory is a standalone example that demonstrates how to use the JCE API in Tongsuo OpenJDK.
The example depends on tongsuo-openjdk. You need to build tongsuo-openjdk or download it from maven repository.
Take TLS13Client and TLS13Server as an example.

## Quick Start (Recommended)

The easiest way to run examples is using the provided convenience scripts with the uber JAR:

```shell
cd examples/jce

# Download uber JAR (static version - no external dependencies)
wget https://github.com/Tongsuo-Project/tongsuo-java-sdk/releases/download/v1.1.0/tongsuo-openjdk-1.1.0-uber.jar

# Download BouncyCastle (for server only)
wget https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk15on/1.69/bcprov-jdk15on-1.69.jar

# Run client
./run-client.sh tongsuo-openjdk-1.1.0-uber.jar

# Run server (in another terminal)
./run-server.sh bcprov-jdk15on-1.69.jar tongsuo-openjdk-1.1.0-uber.jar
```

The scripts will automatically:
- ✅ Detect your Java version
- ✅ Add required JVM parameters (Java 9+)
- ✅ Compile the code if needed
- ✅ Run the example

## Prerequisites

**Java 9+ Module System:** When using Java 9 or later, you need to add JVM parameters to allow Conscrypt to access internal Java APIs:

```shell
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/sun.security.x509=ALL-UNNAMED
```

The convenience scripts (`run-client.sh` and `run-server.sh`) handle this automatically.

## TLS13Client

### Using Convenience Script (Recommended)

```shell
cd examples/jce

# build
javac -cp /path/to/tongsuo-openjdk-<version>-<os>-<arch>.jar TLS13Client.java
# Basic usage
./run-client.sh tongsuo-openjdk-1.1.0-uber.jar

# run
java -cp .:/path/to/tongsuo-openjdk-<version>-<os>-<arch>.jar TLS13Client
# Force recompilation
./run-client.sh --force-compile tongsuo-openjdk-1.1.0-uber.jar
```

### Manual Usage

```shell
cd examples/jce

# Build
javac -cp tongsuo-openjdk-1.1.0-uber.jar TLS13Client.java

# Run (Java 9+)
java --add-opens java.base/java.net=ALL-UNNAMED \
--add-opens java.base/sun.security.x509=ALL-UNNAMED \
-cp .:tongsuo-openjdk-1.1.0-uber.jar \
TLS13Client

# Run (Java 8)
java -cp .:tongsuo-openjdk-1.1.0-uber.jar TLS13Client
```

## TLS13Server

TLS13Server depends on bouncycastle and tongsuo-openjdk. You need to download bcprov-jdk from maven repository.
**Note:** The server requires:
- BouncyCastle JAR (`bcprov-jdk15on-1.69.jar`)
- Certificate files: `sm2.crt`, `sm2.key`, `chain.crt` (provided in this directory)

### Using Convenience Script (Recommended)

Note: sm2.crt, sm2.key and chain.crt are required to run the server.
```shell
cd examples/jce

# Basic usage
./run-server.sh bcprov-jdk15on-1.69.jar tongsuo-openjdk-1.1.0-uber.jar

# Force recompilation
./run-server.sh --force-compile bcprov-jdk15on-1.69.jar tongsuo-openjdk-1.1.0-uber.jar
```

### Manual Usage

```shell
cd examples/jce

# build
javac -cp /path/to/bcprov-jdk15on-1.69.jar:/path/to/tongsuo-openjdk-<version>-<os>-<arch>.jar TLS13Server.java
# Build
javac -cp bcprov-jdk15on-1.69.jar:tongsuo-openjdk-1.1.0-uber.jar TLS13Server.java

# Run (Java 9+)
java --add-opens java.base/java.net=ALL-UNNAMED \
--add-opens java.base/sun.security.x509=ALL-UNNAMED \
-cp .:bcprov-jdk15on-1.69.jar:tongsuo-openjdk-1.1.0-uber.jar \
TLS13Server

# run
java -cp .:/path/to/bcprov-jdk15on-1.69.jar:/path/to/tongsuo-openjdk-<version>-<os>-<arch>.jar TLS13Server
# Run (Java 8)
java -cp .:bcprov-jdk15on-1.69.jar:tongsuo-openjdk-1.1.0-uber.jar TLS13Server
```

## Choosing the Right JAR

We provide two uber JARs:

### Static Uber JAR (Recommended) ⭐
- **Filename:** `tongsuo-openjdk-{version}-uber.jar`
- **Size:** ~15-20 MB
- **Dependencies:** None - all Tongsuo libraries are statically linked
- **Use when:** You want simplicity and portability
- **Pros:** Works everywhere, no installation required
- **Cons:** Larger file size

### Dynamic Uber JAR (Advanced)
- **Filename:** `tongsuo-openjdk-{version}-dynamic-uber.jar`
- **Size:** ~1-2 MB
- **Dependencies:** **Requires Tongsuo installed on your system**
- **Use when:** You have Tongsuo already installed system-wide
- **Pros:** Much smaller file size, can use system-optimized libraries
- **Cons:** Requires system setup

#### Installing Tongsuo (for Dynamic Uber JAR)

**macOS:**
```bash
brew install tongsuo
# Or build from source and install to /usr/local
```

**Linux:**
```bash
# Install to /usr/local/lib
sudo ldconfig # Update library cache
```

**Windows:**
```bash
# Add Tongsuo bin/ directory to PATH
```

**For most users, the static uber JAR is recommended** as it requires no system setup.

## Troubleshooting

### InaccessibleObjectException (Java 9+)

**Error:**
```
java.lang.reflect.InaccessibleObjectException: Unable to make java.net.InetAddress$InetAddressHolder java.net.InetAddress.holder() accessible
```

**Solution:** Add the required JVM parameters:
```bash
java --add-opens java.base/java.net=ALL-UNNAMED \
--add-opens java.base/sun.security.x509=ALL-UNNAMED \
-cp .:tongsuo-openjdk-1.1.0-uber.jar \
YourClass
```

Or use the convenience scripts which handle this automatically.

### UnsatisfiedLinkError (Dynamic Uber JAR only)

**Error:**
```
java.lang.UnsatisfiedLinkError: ... libssl.3.dylib ... no such file
```

**Solution:** Install Tongsuo on your system:
- **macOS:** `brew install tongsuo`
- **Linux:** Install to `/usr/local/lib` and run `sudo ldconfig`

Or switch to the static uber JAR which has no external dependencies.

### Compilation Errors

If you encounter compilation errors, try forcing recompilation:
```bash
./run-client.sh --force-compile tongsuo-openjdk-1.1.0-uber.jar
./run-server.sh --force-compile bcprov-jdk15on-1.69.jar tongsuo-openjdk-1.1.0-uber.jar
```

## Complete Example Session

```bash
cd examples/jce

# 1. Download dependencies
wget https://github.com/Tongsuo-Project/tongsuo-java-sdk/releases/download/v1.1.0/tongsuo-openjdk-1.1.0-uber.jar
wget https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk15on/1.69/bcprov-jdk15on-1.69.jar

# 2. Start server in one terminal
./run-server.sh bcprov-jdk15on-1.69.jar tongsuo-openjdk-1.1.0-uber.jar

# 3. In another terminal, run client
./run-client.sh tongsuo-openjdk-1.1.0-uber.jar
```

That's it! The scripts handle everything else automatically. 🎉
53 changes: 40 additions & 13 deletions examples/jce/TLS13Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class TLS13Client {
public static void main(String[] args)throws Exception{
String ip = "127.0.0.1";
int port = 443;
int port = 8443;
String ciperSuites = "TLS_SM4_GCM_SM3:TLS_SM4_CCM_SM3";
String caCert = "chain.crt";

Expand Down Expand Up @@ -79,28 +79,55 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) throws
}

BufferedWriter out = new BufferedWriter(new OutputStreamWriter(sslSocket.getOutputStream()));
System.out.println("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
System.out.println("Sending HTTP request to server...");
System.out.println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
out.write("GET / HTTP/1.0\r\n\r\n");
out.flush();

System.out.println("client ssl send msessage success...");
System.out.println("Request sent successfully");

BufferedInputStream streamReader = new BufferedInputStream(sslSocket.getInputStream());
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(streamReader, "utf-8"));

System.out.println("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
System.out.println("Response from server:");
System.out.println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");

String line = null;
int lineCount = 0;
while((line = bufferedReader.readLine())!= null){
System.out.println("client receive server data:" + line);
System.out.println(line);
lineCount++;
}

if (lineCount == 0) {
System.out.println("⚠️ No data received from server!");
} else {
System.out.println("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
System.out.println("✅ Successfully received " + lineCount + " lines from server");
System.out.println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
}

while (true) {
try {
sslSocket.sendUrgentData(0xFF);
Thread.sleep(1000L);
System.out.println("client waiting server close");
} catch (Exception e) {
bufferedReader.close();
out.close();
sslSocket.close();
}
// Close resources in correct order: writers first, then readers, then socket
try {
out.close();
} catch (Exception e) {
// Ignore close errors
}

try {
bufferedReader.close();
} catch (Exception e) {
// Ignore close errors
}

try {
sslSocket.close();
} catch (Exception e) {
// Ignore close errors
}

System.out.println("\nConnection closed");
}
}
54 changes: 42 additions & 12 deletions examples/jce/TLS13Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void main(String[] args)throws Exception{
System.out.println("Server SSL context init success...");

SSLServerSocketFactory socketFactory = sslContext.getServerSocketFactory();
SSLServerSocket serverSocket = (SSLServerSocket)socketFactory.createServerSocket(443);
SSLServerSocket serverSocket = (SSLServerSocket)socketFactory.createServerSocket(8443);

if(ciperSuites != null && !"".equals(ciperSuites.trim())){
String[] ciperSuiteArray = ciperSuites.split(":");
Expand All @@ -79,24 +79,54 @@ public static void main(String[] args)throws Exception{

while (true){
SSLSocket sslSocket = (SSLSocket)serverSocket.accept();
System.out.println("Client connected from: " + sslSocket.getInetAddress());

try {
BufferedReader in = new BufferedReader( new InputStreamReader(sslSocket.getInputStream()) );
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(sslSocket.getOutputStream()));
String msg = null;
char[] cbuf = new char[1024];
int len = 0;
while((len = in.read(cbuf, 0, 1024)) != -1 ){
msg = new String(cbuf, 0, len);
out.write(msg);
out.flush();

if("Bye".equals(msg)) {
break;

// Read the HTTP request
String requestLine = null;
StringBuilder request = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
if (requestLine == null) {
requestLine = line;
}
request.append(line).append("\n");
// HTTP request ends with an empty line
if (line.isEmpty()) {
break;
}
System.out.printf("Received Message --> %s \n", msg);
}

System.out.println("Received request:");
System.out.println(request.toString());

// Send HTTP response
String response = "HTTP/1.0 200 OK\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n" +
"Content-Length: 116\r\n" +
"Connection: close\r\n" +
"\r\n" +
"<html>\n" +
"<head><title>Tongsuo TLS 1.3 Server</title></head>\n" +
"<body>\n" +
"<h1>Hello from Tongsuo!</h1>\n" +
"<p>TLS 1.3 with SM cipher suites is working! 🎉</p>\n" +
"</body>\n" +
"</html>\n";

out.write(response);
out.flush();
System.out.println("Response sent successfully");

// Close the connection
sslSocket.close();
System.out.println("Connection closed\n");

} catch (IOException e){
System.err.println("Error handling client connection:");
e.printStackTrace();
}
}
Expand Down
Loading