Skip to content
AoceanPPublic

About

TLS configuration auditor in Java 21: tests every protocol version and cipher suite one by one, checks the certificate like a browser, and grades the server A to F with a reason for every point lost.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

tlsaudit

A TLS configuration auditor in Java 21: it connects to a server, finds out exactly which protocol versions and cipher suites it accepts, checks its certificate the way a browser would, and grades it from A to F with a reason for every point lost.

Only audit servers you own or have permission to test. The tests use their own local servers and a throwaway test CA, so they contact nothing outside your machine.

Overview

What

tlsaudit example.com

It reports:

  • every protocol version the server accepts, from SSL 3.0 to TLS 1.3;
  • every cipher suite it accepts, each rated;
  • its certificate: whether the chain is trusted, its dates, its host names, its key size and its signature algorithm;
  • whether it sends HSTS.

It ends with a grade from A to F. Every finding says the best grade it still allows, so the grade can always be explained.

Problem

TLS is what puts the padlock in the address bar, and it fails quietly. A server can work perfectly in every modern browser and still accept TLS 1.0 from an old client, offer cipher suites without forward secrecy, or send a certificate that expires next week. A normal client never notices: it offers its best options, the server picks one, and everything looks fine.

The usual answer is an online scanner, which only reaches public servers. tlsaudit runs anywhere Java runs, including against internal servers, test environments and devices on a private network.

Solution

  • Ask one question per handshake. The server is offered one protocol at a time, then one cipher suite at a time, so it has to reveal everything it accepts, including the weak options it only uses with old clients.
  • Accept, then judge. During the handshake every certificate is accepted, so even an expired or self-signed one can be examined. It is judged afterwards, with separate findings for trust, dates, host name, key and signature, each with its own message.
  • Name the attack, not just the setting. Each weakness says why it matters: "3DES has 64-bit blocks (Sweet32)", "no forward secrecy: a stolen server key decrypts recorded traffic", "SSL 3.0 is accepted (broken by POODLE)".
  • A grade you can trace. The grade is the worst cap among all findings, so the report always shows which finding caused it.

Why I built it

To understand what TLS actually negotiates and what goes wrong in practice: knowledge every network and security engineer is expected to have.

Concept Where it lives
The TLS handshake: protocol and cipher-suite negotiation, SNI TlsProbe
Reading a cipher suite name: key exchange, forward secrecy, AEAD vs CBC CipherRating
X.509 certificates and PKIX chain validation CertificateCheck.trust
Host-name rules: subjectAltName, wildcards, IP entries (RFC 6125) HostnameMatcher
Key sizes and signature algorithms (RSA, EC, SHA-1, MD5) CertificateCheck.key, signatures
HSTS and SSL stripping Auditor.hsts
Java security architecture: SSLContext, trust managers, security properties TlsProbe
Testing against misconfigured servers built in the test itself TestServer, 27 JUnit tests

Part of a project series

Each project looks at the same network from a different side:

Project Language View Question it answers
portscout Java 21 the attacker's view What ports are open, and what is running behind them?
wiresight C++20 the network's view What is actually on the wire?
tlsaudit (this one) Java 21 the encryption's view Can the connection itself be trusted?
logonwatch C# / .NET 10 the defender's view Is someone trying to break in, and did they get in?
tracekeep Python the evidence's view Can the logs still be trusted afterwards?

portscout finds the open ports; tlsaudit checks the encryption on the ones that speak TLS. It also audits tracekeep's collector when its TLS mode is on: tlsaudit 127.0.0.1:5140 --ca tests/certs/ca.pem --no-http (run from the tracekeep folder) gives it an A: TLS 1.3 only, three strong suites, and a valid certificate.

Quick start

You need a JDK 21 or newer. Gradle comes with the project.

gradlew test
gradlew installDist
build\install\tlsaudit\bin\tlsaudit example.com

On macOS and Linux use ./gradlew and build/install/tlsaudit/bin/tlsaudit.

Usage

tlsaudit <host>[:port] [options]
Option Meaning Default
host[:port] a name, an IPv4 address, or an IPv6 address in brackets ([::1]:8443) port 443
-p, --port N the port 443
-t, --timeout MS connect and read timeout per handshake 3000
--ca FILE.pem trust these root certificates instead of Java's trust store (for a private CA) Java's cacerts
--no-ciphers skip testing every cipher suite one by one: much faster off
--no-http skip the HTTP request that checks HSTS (for TLS services that are not websites) off
--json print JSON instead of text off

Exit codes: 0 for grade A, 3 for B to F, 1 if the server cannot be reached, 2 for a bad command line. A CI job can fail a deployment on exit code 3.

Example: a server stuck on TLS 1.0

badssl.com runs deliberately broken servers for testing TLS clients. This is its TLS 1.0 server:

> tlsaudit tls-v1-0.badssl.com:1010 --no-http
tlsaudit  tls-v1-0.badssl.com:1010  grade C

protocols    TLS 1.3 no   TLS 1.2 no   TLS 1.1 no   TLS 1.0 yes   SSL 3.0 no
certificate  CN=*.badssl.com
issued by    CN=YR1,O=Let's Encrypt,C=US
valid        2026-09-29 to 2026-12-28
names        *.badssl.com, badssl.com
cipher suites accepted: 6
  TLS 1.0  TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA      B  CBC mode (padding-oracle attacks such as Lucky13)
  TLS 1.0  TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA      B  CBC mode (padding-oracle attacks such as Lucky13)
  TLS 1.0  TLS_DHE_RSA_WITH_AES_256_CBC_SHA        B  CBC mode (padding-oracle attacks such as Lucky13)
  TLS 1.0  TLS_DHE_RSA_WITH_AES_128_CBC_SHA        B  CBC mode (padding-oracle attacks such as Lucky13)
  TLS 1.0  TLS_RSA_WITH_AES_256_CBC_SHA            B  no forward secrecy: a stolen server key decrypts recorded traffic
  TLS 1.0  TLS_RSA_WITH_AES_128_CBC_SHA            B  no forward secrecy: a stolen server key decrypts recorded traffic

findings
  WARN  protocol    TLS 1.3 not supported  [max B]
  WARN  protocol    TLS 1.0 is still accepted (deprecated since 2021, RFC 8996)  [max C]
  OK    trust       chain is trusted (3 certificates sent)
  OK    dates       certificate valid until 2026-12-28 (57 days)
  OK    hostname    certificate is valid for tls-v1-0.badssl.com
  OK    key         RSA 2048-bit key
  OK    signature   certificate signed with SHA256withRSA
  WARN  cipher      4 accepted suites with CBC mode (padding-oracle attacks such as Lucky13): ...  [max B]
  WARN  cipher      2 accepted suites with no forward secrecy: ...  [max B]

The wildcard certificate *.badssl.com correctly covers tls-v1-0.badssl.com, so only the protocol and the suites cost points. Other badssl.com servers gave, on this machine:

Server Grade The finding that set it
expired.badssl.com F certificate expired 4220 days ago (2015-04-12), and an intermediate in 2020
self-signed.badssl.com F self-signed certificate: no browser trusts it
sha1-intermediate.badssl.com F expired, plus the intermediate signed with SHA1withRSA (C on its own)
3des.badssl.com C TLS 1.0 and 1.1 still accepted (it only offers 3DES suites; see the bug below)

Many port-443 connections to badssl.com timed out from this network during testing, so tlsaudit retries a connection once before giving up.

How the grade works

The grade is the worst cap of all findings. Each check can only pull the grade down so far:

Grade Means Caused by
A modern and correct nothing below
B safe, missing something modern no TLS 1.3; suites without forward secrecy or in CBC mode; no HSTS, or HSTS under 6 months; certificate expires within 30 days
C works, but deprecated TLS 1.0 or 1.1 accepted; 3DES (Sweet32); RSA/DSA key under 2048 bits or EC under 256; SHA-1 signature
F broken untrusted or self-signed chain; expired or not-yet-valid certificate (server or intermediate); host name not covered; SSL 3.0 (POODLE); NULL, anonymous, EXPORT, RC4 or DES suites; MD5 signature; no TLS at all

How it works

  1. Protocols: one handshake per version, newest first, each offering only that version and every suite Java supports. The first success provides the certificate chain.
  2. Certificate: checked by CertificateCheck against Java's trust store (or --ca):
    • trust: PKIX validation, without revocation, at a moment inside every certificate's validity;
    • dates: checked against the real clock, separately, so an expired certificate is reported as expired, not as untrusted;
    • host name: matched against subjectAltName only, as browsers do;
    • key size and signature: checked last.
  3. Cipher suites: each suite Java implements is offered on its own with each accepted protocol, eight handshakes at a time, and every accepted suite is rated by its name.
  4. HSTS: an HTTP HEAD request over TLS, then the Strict-Transport-Security header and its max-age.
  5. Grade and report: the worst cap, as text or JSON. Certificate names come from the server, so they are escaped in JSON.

Two deliberate exceptions to Java's safe defaults, in this process only:

  • Every certificate is accepted during the handshake, so a bad one can be inspected.
  • Java's disabled-algorithm lists are emptied, so SSL 3.0, TLS 1.0 and weak suites can be offered, to see whether the server accepts them.

No secret is ever sent over these connections. This is why tlsaudit must never be used as a library for real traffic.

A bug the real servers found: 3des.badssl.com was first graded F, "does not speak TLS". The protocol check offered Java's default cipher list, and recent Java versions leave 3DES out of it, so a server with only 3DES suites refused every handshake. The check now offers every suite Java supports, and a test (serverWithOnlyOldSuitesStillSpeaksTls) keeps it that way.

Design

tlsaudit class diagram

tlsaudit program flow

Both are drawn in draw.io: tlsaudit-uml.drawio, tlsaudit-flow.drawio.

Tests

27 JUnit tests, run with gradlew test. They need no network: every server is started inside the test on 127.0.0.1.

File What it covers
AuditorTest.java whole audits of local servers, each with one problem:
• a modern server (A)
• TLS 1.2 only (B)
• TLS 1.0 and 1.1 left on (C)
• RSA key exchange found by the suite test (B)
• 3DES (C)
• a server with only 3DES
• self-signed (F)
• HSTS missing, short, or not HTTP
• a plain TCP port (F)
• a closed port (error)
CertificateCheckTest.java a good chain passes everything; a private CA is untrusted by default; self-signed is named; a wrong host fails only the host-name check; a 1024-bit key and SHA-1 are reported separately from trust; EC keys are rated by EC rules; dates judged at four moments with a fixed clock; host names, addresses and every wildcard rule
ParsingTest.java target forms and refusals, every cipher rule, protocol findings, grades, JSON escaping of server-controlled text, the command line and its exit codes

The test certificates in src/test/resources/certs are made by scripts/make-test-certs.sh with keytool:

  • What it makes: a test CA, then good, wrong-host, weak (RSA 1024 + SHA-1), elliptic-curve and self-signed server certificates.
  • The CA's private key is deleted at the end, so nothing else can ever be signed with it.
  • The server keys are public test files and protect nothing.

What it does not do

  • Revocation (OCSP, CRL) is not checked. That would mean calling the certificate authority for every audit.
  • Implementation bugs such as Heartbleed or ROBOT are not probed. Those need hand-crafted packets, not configuration checks.
  • Only suites Java implements can be tested. A suite Java dropped (RC4, EXPORT) cannot be offered, so a server accepting only those would show "does not speak TLS". SSL 2.0 is not tested for the same reason.

Roadmap

  • Protocols, every cipher suite, certificate, HSTS, A to F grade, text and JSON
  • Certificate Transparency: check the certificate's SCTs
  • OCSP stapling: report whether the server staples a revocation response
  • Audit many hosts from a file and print one summary table

License

MIT, Copyright (c) 2026 AoceanP. See LICENSE.

Edge cases

Situation Result Why
Expired certificate from a trusted CA F for dates, trust still OK the fix (renew) is different from an untrusted chain (wrong CA)
Certificate valid only in the future F clocks and staging certificates go wrong too
Expires within 30 days B a warning while there is still time to renew
Server sends the root certificate too root ignored trust must come from the trust store, not from the server
*.example.com vs example.com, a.b.example.com no match a wildcard covers exactly one label (CertificateCheckTest)
*.com, w*.example.com, *.*.example.com never match refused patterns, as browsers do
Name only in the Common Name, not in subjectAltName no match browsers ignore the CN since 2017
127.0.0.1 against a certificate for localhost matched only by an IP entry names never match addresses
Port open but not TLS (SSH, plain HTTP) F, "no TLS handshake succeeded" not a crash (AuditorTest)
Nothing listening exit code 1, "cannot reach" an error, not a grade
One connection times out mid-audit retried once one lost packet must not fail an audit
HSTS header in lower case, quoted max-age understood header names are case-insensitive (AuditorTest)
A certificate name containing " or control characters escaped in JSON the server controls that text (ParsingTest)
example.com:http, https://example.com, [::1 refused before connecting a typo is a usage error, not a network error

About

TLS configuration auditor in Java 21: tests every protocol version and cipher suite one by one, checks the certificate like a browser, and grades the server A to F with a reason for every point lost.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages