{"id":34985632,"url":"https://github.com/gkhays/mtls-java","last_synced_at":"2026-05-19T23:02:51.776Z","repository":{"id":321298190,"uuid":"1085108778","full_name":"gkhays/mtls-java","owner":"gkhays","description":"Mutual TLS scenarios in Java","archived":false,"fork":false,"pushed_at":"2025-10-31T21:13:24.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-22T18:46:44.905Z","etag":null,"topics":["java","mtls","tls"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gkhays.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-28T15:41:36.000Z","updated_at":"2025-10-31T21:13:23.000Z","dependencies_parsed_at":"2025-10-28T23:27:08.559Z","dependency_job_id":"0a4fcc8d-fbc7-43bf-a505-904ed92d9e5b","html_url":"https://github.com/gkhays/mtls-java","commit_stats":null,"previous_names":["gkhays/mtls-java"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gkhays/mtls-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkhays%2Fmtls-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkhays%2Fmtls-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkhays%2Fmtls-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkhays%2Fmtls-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gkhays","download_url":"https://codeload.github.com/gkhays/mtls-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkhays%2Fmtls-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33236803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T15:49:41.270Z","status":"ssl_error","status_checked_at":"2026-05-19T15:49:22.917Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","mtls","tls"],"created_at":"2025-12-27T01:31:53.283Z","updated_at":"2026-05-19T23:02:51.770Z","avatar_url":"https://github.com/gkhays.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mutual TLS Scenarios in Java\n\nThis project demonstrates various mutual TLS (mTLS) scenarios in Java, including certificate validation and Extended Key Usage (EKU) restrictions.\n\n## Features\n\n### Single-Use Client Certificates\n\nThe project supports creating and testing single-use client certificates with `serverAuth` Extended Key Usage (EKU) instead of the standard `clientAuth` EKU. This demonstrates certificate-based access control scenarios.\n\n### Dual-Use Certificates\n\nThe project also supports creating dual-use certificates that have both `clientAuth` and `serverAuth` Extended Key Usage (EKU), allowing certificates to be used for both client and server authentication scenarios.\n\n#### Creating Single-Use Certificates\n\nUse the `-single-use` flag with the keystore creation script:\n\n```bash\n# Create a single-use client certificate with serverAuth EKU\ncd scripts\n./create-keystore.sh -client -single-use\n```\n\n#### Creating Dual-Use Certificates\n\nUse the `-dual-use` flag with the keystore creation script:\n\n```bash\n# Create certificates with both clientAuth and serverAuth EKU\ncd scripts\n./create-keystore.sh -all -dual-use\n```\n\n#### Cleaning Generated Files\n\nRemove all generated JKS files:\n\n```bash\n# Clean all JKS files from script directory and src/main/resources\ncd scripts\n./create-keystore.sh -clean\n```\n\n#### Using Single-Use Mode in Java Application\n\nThe Java application recognizes the `-single-use` flag:\n\n```bash\n# Run with single-use mode awareness\njava -cp target/classes com.github.tls.App -single-use\n```\n\nWhen `-single-use` flag is used:\n- The application indicates it expects serverAuth EKU in the client certificate\n- Certificate extensions are inspected and displayed\n- The TLS handshake will fail as expected (serverAuth EKU cannot be used for client authentication)\n\n#### Keystore Creation Options\n\n```bash\n./create-keystore.sh [-all|-client|-server|-clean] [-single-use|-dual-use]\n```\n\n- `-all`: Create both client.jks and server.jks keystores plus truststore.jks (default)\n- `-client`: Create client.jks keystore with client certificate plus truststore.jks  \n- `-server`: Create server.jks keystore with server certificate plus truststore.jks\n- `-clean`: Remove all JKS files from script directory and src/main/resources\n- `-single-use`: Set serverAuth EKU in client certificate for single-use scenarios\n- `-dual-use`: Set both clientAuth and serverAuth EKU in both client and server certificates\n\n**Note:** The `-single-use` and `-dual-use` options are mutually exclusive.\n\n#### Examples\n\n```bash\n# Create complete mTLS setup with standard certificates (default)\n./create-keystore.sh\n\n# Create only client certificate and truststore\n./create-keystore.sh -client\n\n# Create only server certificate and truststore  \n./create-keystore.sh -server\n\n# Create single-use client certificate (serverAuth EKU only)\n./create-keystore.sh -client -single-use\n\n# Create dual-use certificates (both clientAuth and serverAuth EKU)\n./create-keystore.sh -all -dual-use\n\n# Clean all generated JKS files\n./create-keystore.sh -clean\n```\n\nAll keystores are automatically copied to `src/main/resources` for use by the Java application.\n\n#### Test Script\n\nRun the complete demonstration:\n\n```bash\ncd scripts\n./test-single-use.sh\n```\n\nThis script demonstrates:\n1. Normal mTLS with clientAuth EKU (works)\n2. Single-use certificate with serverAuth EKU (fails as expected)\n3. Application recognition of single-use mode\n\n## Troubleshooting\n\n```bash\nStarting client communication...\nClient keystore loaded successfully (CA-signed certificate)\nClient truststore loaded successfully (contains CA certificate)\n\n--- Common Extensions (Parsed) ---\nBasic Constraints: CA: false\nKey Usage:\n  Digital Signature\n  Non Repudiation\n  Key Encipherment\n  Data Encipherment\nExtended Key Usage:\n  Server Authentication (1.3.6.1.5.5.7.3.1)\nSubject Alternative Names:\n  DNS Name: localhost\n  IP Address: 127.0.0.1\nClient connected: /127.0.0.1\nError handling client connection: Extended key usage does not permit use for TLS client authentication\nServer is waiting for connection...\njava.net.SocketException: An established connection was aborted by the software in your host machine\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkhays%2Fmtls-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgkhays%2Fmtls-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkhays%2Fmtls-java/lists"}