-
Notifications
You must be signed in to change notification settings - Fork 6.3k
8301626: Capture Named Group information in TLSHandshakeEvent #31371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -562,7 +562,7 @@ private void onConsumeFinished(ClientHandshakeContext chc, | |
|
|
||
| // handshake context cleanup. | ||
| chc.handshakeFinished = true; | ||
| recordEvent(chc.conContext.conSession); | ||
| recordEvent(chc); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We record an event both on consuming and on producing Finished:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind, I see now that we actually log only once on each side: client producing and server consuming. |
||
|
|
||
| // May need to retransmit the last flight for DTLS. | ||
| if (!chc.sslContext.isDTLS()) { | ||
|
|
@@ -623,7 +623,7 @@ private void onConsumeFinished(ServerHandshakeContext shc, | |
|
|
||
| // handshake context cleanup. | ||
| shc.handshakeFinished = true; | ||
| recordEvent(shc.conContext.conSession); | ||
| recordEvent(shc); | ||
|
|
||
| // May need to retransmit the last flight for DTLS. | ||
| if (!shc.sslContext.isDTLS()) { | ||
|
|
@@ -765,7 +765,7 @@ private byte[] onProduceFinished(ClientHandshakeContext chc, | |
| // handshake context cleanup. | ||
| chc.handshakeFinished = true; | ||
| chc.conContext.finishHandshake(); | ||
| recordEvent(chc.conContext.conSession); | ||
| recordEvent(chc); | ||
|
|
||
|
|
||
| // The handshake message has been delivered. | ||
|
|
@@ -1164,7 +1164,7 @@ private void onConsumeFinished(ServerHandshakeContext shc, | |
| if (!shc.sslContext.isDTLS()) { | ||
| shc.conContext.finishHandshake(); | ||
| } | ||
| recordEvent(shc.conContext.conSession); | ||
| recordEvent(shc); | ||
|
|
||
| // | ||
| // produce | ||
|
|
@@ -1174,9 +1174,10 @@ private void onConsumeFinished(ServerHandshakeContext shc, | |
| } | ||
| } | ||
|
|
||
| private static void recordEvent(SSLSessionImpl session) { | ||
| private static void recordEvent(HandshakeContext hc) { | ||
| TLSHandshakeEvent event = new TLSHandshakeEvent(); | ||
| if (event.shouldCommit() || EventHelper.isLoggingSecurity()) { | ||
| SSLSessionImpl session = hc.conContext.conSession; | ||
| int hash = 0; | ||
| try { | ||
| // use hash code for Id | ||
|
|
@@ -1187,12 +1188,20 @@ private static void recordEvent(SSLSessionImpl session) { | |
| // not verified msg | ||
| } | ||
| long peerCertificateId = Integer.toUnsignedLong(hash); | ||
| String namedGroup = "N/A"; | ||
| for (SSLCredentials cred : hc.handshakeCredentials) { | ||
| if (cred instanceof NamedGroupCredentials ngCred) { | ||
| namedGroup = ngCred.getNamedGroup().name; | ||
| break; | ||
| } | ||
| } | ||
| if (event.shouldCommit()) { | ||
| event.peerHost = session.getPeerHost(); | ||
| event.peerPort = session.getPeerPort(); | ||
| event.cipherSuite = session.getCipherSuite(); | ||
| event.protocolVersion = session.getProtocol(); | ||
| event.certificateId = peerCertificateId; | ||
| event.namedGroup = namedGroup; | ||
| event.commit(); | ||
| } | ||
| if (EventHelper.isLoggingSecurity()) { | ||
|
|
@@ -1201,6 +1210,7 @@ private static void recordEvent(SSLSessionImpl session) { | |
| session.getPeerPort(), | ||
| session.getCipherSuite(), | ||
| session.getProtocol(), | ||
| namedGroup, | ||
| peerCertificateId); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
namedGroupis being logged right aftercipherSuite, it will be consistent to keep the same order here and insrc/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java