-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add key log callback option to SSLContext (#861)
Motivation: Wireshark can decrypt TLS sessions during packet capture, if the session keys (etc.) are available from an SSL key log file. This log file format has become a de facto industry standard, and BoringSSL (and maybe the others too, didn't check) has a callback mechanism for delivering log lines in this format. Modification: Add `KeyLogCallback` interface and an `SSLContext.setKeyLogCallback` method, which integrators can easily implement the SSLKEYLOGFILE feature, or equivalent, on top of. Result: It is now possible to configure netty-tcnative in a way that TLS sessions can be decrypted at packet-capture time by Wireshark, making it easier to investigate and debug problems with TLS. --------- Co-authored-by: Norman Maurer <[email protected]>
- Loading branch information
1 parent
f188fce
commit 0cb6518
Showing
4 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
openssl-classes/src/main/java/io/netty/internal/tcnative/KeyLogCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2024 The Netty Project | ||
* | ||
* The Netty Project licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.netty.internal.tcnative; | ||
|
||
/** | ||
* Callback hooked into <a href="https://github.com/google/boringssl/blob/master/include/openssl/ssl.h#L4379">SSL_CTX_set_keylog_callback</a> | ||
* This is intended for TLS debugging with tools like <a href="https://wiki.wireshark.org/TLS">Wireshark</a>. | ||
* For instance, a valid {@code SSLKEYLOGFILE} implementation could look like this: | ||
* <pre>{@code | ||
* final PrintStream out = new PrintStream("~/tls.sslkeylog_file"); | ||
* SSLContext.setKeyLogCallback(ctxPtr, new KeyLogCallback() { | ||
* @Override | ||
* public void handle(long ssl, byte[] line) { | ||
* out.println(new String(line)); | ||
* } | ||
* }); | ||
* }</pre> | ||
* <p> | ||
* <strong>Warning:</strong> The log output will contain secret key material, and can be used to decrypt | ||
* TLS sessions! The log output should be handled with the same care given to the private keys. | ||
*/ | ||
public interface KeyLogCallback { | ||
/** | ||
* Called when a new key log line is emitted. | ||
* <p> | ||
* <strong>Warning:</strong> The log output will contain secret key material, and can be used to decrypt | ||
* TLS sessions! The log output should be handled with the same care given to the private keys. | ||
* | ||
* @param ssl the SSL instance | ||
* @param line an array of the key types on client-mode or {@code null} on server-mode. | ||
* | ||
*/ | ||
void handle(long ssl, byte[] line); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters