I’ve done a lot of work using TLS, and Wireshark is a great tool for displaying the flows of data. The problem is understanding what the output shows! This blog post shows what to look at.
Note: Flows with GREASE values should be ignored. This is designed to make sure the remote end can handle unexpected values, by sending up unsupported values.
Summary of the flows of the handshake
See here for an overview.
- Client to Server: Client Hello
- Server to Client: Server Hello, Certificate, Server Key Exchange, Certificate Request, Server Hello Done
- Client to Server: Certificate, Client Key Exchange, Certificate Verify, Change Cipher Spec, Finished
- Server to Client: Change Cipher Spec
- Server to Client: Finished
Client to Server: Client Hello
This displays
Transport Layer Security
TLSv1.2 Record Layer: Handshake Protocol: Client Hello
Content Type: Handshake (22)
Version: TLS 1.0 (0x0301)
Handshake Protocol: Client Hello
Handshake Type: Client Hello (1)
Version: TLS 1.2 (0x0303)
Random: c5ec1cf320f2f77ba6f3f84e7fd7d1f946400484a56918a5e499b0e98be2a07f
Session ID Length: 32
Session ID: a839f3fcd1d7f4394c6e5bd0279da5c75458b8a81f35c5890107007cc921fa7b
Cipher Suites Length: 32
▶Cipher Suites (16 suites)
Compression Methods Length: 1
▶Compression Methods (1 method)j
Extensions Length: 429
▶Extension: signature_algorithms
Extension: Reserved (GREASE) (len=0)
▶Extension: supported_versions (len=7)
...
If you expand supported versions you get
Extension: supported_versions (len=7)
...
Supported Version: TLS 1.3 (0x0304)
Supported Version: TLS 1.2 (0x0303)
Which shows you the TLS versions that the client supports.
If you expand Cipher Specs you get
Cipher Suites (16 suites) Cipher Suite: TLS_AES_128_GCM_SHA256 (0x1301) Cipher Suite: TLS_AES_256_GCM_SHA384 (0x1302) Cipher Suite: TLS_CHACHA20_POLY1305_SHA256 (0x1303) Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xc02b) Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) ...
This is the list of cipher specs in preference order, that the client supports.
The signature_algorithms defines which signature and hash algorithms are supported for the server’s digital certificate.
Server to Client: Server Hello, Certificate, Server Key Exchange, Certificate Request, Server Hello Done
The server sends down several blocks of data. These are logically distinct blocks of data – but tend to arrive in one block.
- Server Hello, Here are some parameters for the handshake
- Certificate, Here is my certificate(s)
- Server Key Exchange,
- Certificate Request, Please send me a certificate matching the enclosed parameters
- Server Hello Done
Server to Client: Server Hello
Handshake Protocol: Server Hello Handshake Type: Server Hello (2) Version: TLS 1.2 (0x0303) Random: ... Session ID Length: 32 Session ID: ... Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xc02b) ...
It shows which version of TLS has been picked.
The Cipher Suite is the value picked by the server.
Server to Client: Certificate
This is present if the server is configured to send down the server’s certificate.
Handshake Protocol: Certificate
Handshake Type: Certificate (11)
...
Certificates Length: 1608
Certificates (1608 bytes)
Certificate Length: 734
▼Certificate: .. (commonName=10.1.1.2,...organizationName=NISTECCTEST)
▶signedCertificate
serialNumber: 0x7a
▶signature (sha256WithRSAEncryption)
▶issuer: ...
▶validity ...
▼subject: rdnSequence (0)
RDNSequence (organizationName=NISTECCTEST)
RDNSequence (organizationalUnitName=SSS)
RDNSequence (commonName=10.1.1.2)
▶subjectPublicKeyInfo
▶extensions: 5 items
algorithmIdentifier (sha256WithRSAEncryption)
...
Certificate Length: 868
▶Certificate: ...
From this we can see the certificates sent down from the server.
- The certificate name is specified at many levels; including on the Certificate and subject.
- The CA (issuer) which signed each certificate.
- The validity dates of the certificate
- The extensions, which include how the certificate can be used; key usage, Subject Alternative Name ( IP address) etc.
Check this is what you are expecting, and that the CA is in your trust store.
Server to Client: Server Key Exchange
I have never used the information in this area
Server to Client: Certificate Request
Handshake Protocol: Certificate Request
Certificate types count: 3
▼Certificate types (3 types)
Certificate type: RSA Sign (1)
Certificate type: ECDSA Sign (64)
Certificate type: DSS Sign (2)
▼Signature Hash Algorithms Length: 26
Signature Algorithm: rsa_pkcs1_sha512 (0x0601)
Signature Algorithm: ecdsa_secp521r1_sha512 (0x0603)
...
▼Distinguished Names Length: 246
Distinguished Names (246 bytes)
Distinguished Name: (commonName=COLIN4Certification Authority,...)
Distinguished Name: (commonName=DocZosCA,...)
Distinguished Name: (commonName=SSCA256...)
This is saying please send me a certificate:
- The certificate must be one of certificate-type elements; RSA, ECDSA or DSS,
- and signed by one of the algorithms listed,
- and have a CA signer of COLIN4Certification Authority…, DocZosCA… or SSCA256… .
The CA signers are taken from the server’s trust store.
Server to Client: Server Hello Done
That’s the server side of the work done… almost
Client to Server: Certificate, Client Key Exchange, Certificate Verify, Change Cipher Spec, Finished
Client to Server: Certificate
The client needs to pick a certificate from those in its key store. Depending on the application
- a browser may display a list of valid certificates for the end user to select
- a program may use the information sent down in the handshake to pick the best certificate
- a program may return what the configuration specified (such as default)
- a program may just return the first certificate in the key file.
Handshake Protocol: Certificate
Handshake Type: Certificate (11)
Certificates Length: 683
▼Certificates (683 bytes)
Certificate Length: 680
▼Certificate: … (commonName=docec384,...countryName=GB)
▼signedCertificate
serialNumber: 0x029b
▶signature (ecdsa-with-SHA384)
▼issuer: rdnSequence (0)
▶rdnSequence: 4 items (commonName=SSCA256,OU=CA,iO=DOC,C=GB)
....
▶validity...
▼subject: rdnSequence (0)
▶RDNSequence item: 1 item (countryName=GB)
▶RDNSequence item: 1 item (organizationName=Doc2)
▶RDNSequence item: 1 item (commonName=docec384)
▶subjectPublicKeyInfo
▶extensions: 6 items...
algorithmIdentifier (ecdsa-with-SHA384)
...
We can see
- the algorithm identifier is ecdsa-with-SHA384 which is OK
- the issuer is CN=SSA256,ou=CA,C=GB which is in the list of CAs passed from the server.
- the signature is ecdsa – which is OK
Client to Server: Client Key Exchange
I haven’t used this. If the handshake gets this far, the set-up is good.
Client to Server: Certificate Verify
I have never used this. It is used to send up some data encrypted with the client’s private key, to check the server can decrypt it.
Client to Server: Change Cipher Spec
Response to the server. I have never used this. Business as usual, it periodically changes the Cipher Spec
Finished
Server to Client: Change Cipher Spec
Each direction has its own cipher spec. This is the server saying to the client … ok… I’m using the new cipher spec.
Server to Client: Finished
The final – final completion.
Problems
When an invalid CA was used at the client end, the server sent down
Transport Layer Security
TLSv1.2 Record Layer: Alert (Level: Fatal, Description: Unknown CA)
Content Type: Alert (21)
Version: TLS 1.2 (0x0303)
Alert Message
Level: Fatal (2)
Description: Unknown CA (48)
This has a list of the codes and their meaning.