TLS validation of wildcard subjectAltName domain + SSLKEYLOGFILE support#187
TLS validation of wildcard subjectAltName domain + SSLKEYLOGFILE support#187masneyb merged 2 commits intomasneyb:masterfrom
Conversation
Adding support of TLS validation for wildcard domain names (*.domain.tld) present in certificate subjectAltName field
|
Hi This pull request to solve issue #186: It add support of TLS validation of Kind regards |
|
Hi @masneyb From RFC6125#section-6.4.3:
From RFC2818#section-3.1 (Following RFC2818 is recommended by RFC4217):
Except a mistake from me, adding support of TLS validation for wildcard domains names present in subjectAltName is not just a practical enhancement, it also seems to be year 2025 usage and standards-compliant Kind regards |
|
Hi This new commit add support of OpenSSL SSLKEYLOGFILE to be able to decrypt FTPS TLSv1.2+ traffic using Diffie Hellman and Elliptic Curves like cipher TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 To create SSLKEYLOGFILE, simply run from your shell : export SSLKEYLOGFILE=~/gftp-tls.logAnd launch If you capture traffic with a command like: sudo tcpdump -nnei any -vvvttttXXX 'host <server_ip> and host <client_ip> and (port 21 or port <passive_port>)' -w ~/gftp.pcapYou can pass Enjoy! Kind regards, |
lib/sslcommon.c
Outdated
| * 20250414: Nicolas Baranger | ||
| * Adding support of TLS validation for wildcard domain names (*.domain.tld) | ||
| * present in certificate subjectAltName field | ||
| ****************************************************************************/ |
There was a problem hiding this comment.
Please drop the comments with the names / dates for consistency with the rest of the code. This information is stored in the git commit log. git blame is a useful tool to show exactly what you want here.
lib/sslcommon.c
Outdated
| * Adding support of TLS validation for wildcard domain names (*.domain.tld) | ||
| * present in certificate subjectAltName field | ||
| ****************************************************************************/ | ||
| /* Commenting existing code */ |
lib/sslcommon.c
Outdated
| } | ||
| /************************************************************************** | ||
| * END OF MODIFICATIONS | ||
| ****************************************************************************/ |
|
Hi Brian Thanks for answer and help ! Kind regards |
|
Please squash your changes into your previous commits. Here's an article that I found that shows how to do this: https://medium.com/@slamflipstrom/a-beginners-guide-to-squashYou can do |
|
You'll also need to do |
|
Hi Brian After modifying my local repo with suggested changes here is what I did: git add .
git commit --amend
git push origin master --forceHere is a diff summarizing all asked changes: diff --git a/gftp-old/lib/sslcommon.c b/gftp/lib/sslcommon.c
index a22a785..e1302a8 100644
--- a/../sslcommon.c_gftp
+++ b/lib/sslcommon.c
@@ -200,23 +200,7 @@ static int gftp_ssl_post_connection_check (gftp_request * request)
ext_str = meth->d2i(NULL, &mutable_ptr, len);
#endif
val = meth->i2v(meth, ext_str, NULL);
- /**************************************************************************
- * 20250414: Nicolas Baranger
- * Adding support of TLS validation for wildcard domain names (*.domain.tld)
- * present in certificate subjectAltName field
- ****************************************************************************/
- /* Commenting existing code */
- /* for (j = 0; j < sk_CONF_VALUE_num(val); j++)
- {
- nval = sk_CONF_VALUE_value (val, j);
- if (strcmp (nval->name, "DNS") == 0 &&
- strcmp (nval->value, request->hostname) == 0)
- {
- ok = 1;
- break;
- }
- } */
- /* Rewriting 'for' loop with wildcard support (*.domain.tld) in subjectAltName */
+ /* 'for' loop with wildcard support (*.domain.tld) in subjectAltName */
for (j = 0; j < sk_CONF_VALUE_num(val); j++)
{
nval = sk_CONF_VALUE_value(val, j);
@@ -242,9 +226,6 @@ static int gftp_ssl_post_connection_check (gftp_request * request)
}
}
}
- /**************************************************************************
- * END OF MODIFICATIONS
- ****************************************************************************/
}
if (ok)
@@ -352,11 +333,11 @@ static void _gftp_ssl_thread_setup (void)
CRYPTO_set_dynlock_destroy_callback (_gftp_ssl_destroy_dyn_mutex);
}
-/****************************************************************************/
-/* 20250417 Nicolas Baranger */
-/* Adding OpenSSL SSLKEYLOGFILE support */
-/****************************************************************************/
-static void gftp_ssl_keylog_callback(const SSL *ssl, const char *line)
+
+#ifndef __maybe_unused
+#define __maybe_unused __attribute__((__unused__))
+#endif
+static __maybe_unused void gftp_ssl_keylog_callback(const SSL *ssl, const char *line)
{
const char *gftp_keylog_file = getenv("SSLKEYLOGFILE");
if (!gftp_keylog_file)
@@ -369,9 +350,6 @@ static void gftp_ssl_keylog_callback(const SSL *ssl, const char *line)
fprintf(gftp_fp, "%s\n", line);
fclose(gftp_fp);
}
-/***************************************************************************/
-/* END ADDITIONS */
-/****************************************************************************/
int gftp_ssl_startup (gftp_request * request)
I let this comment at line 203 in lib/sslcommon.c:: /* 'for' loop with wildcard support (*.domain.tld) in subjectAltName */Let me know if it's ok, I stay available if needed Thanks again |
lib/sslcommon.c
Outdated
| break; | ||
| } | ||
| } | ||
| /* 'for' loop with wildcard support (*.domain.tld) in subjectAltName */ |
lib/sslcommon.c
Outdated
|
|
||
| #ifndef __maybe_unused | ||
| #define __maybe_unused __attribute__((__unused__)) | ||
| #endif |
There was a problem hiding this comment.
I know I suggested this earlier, however it can be dropped. Sorry. I didn't have time when I first did a review for a more thorough review.
There was a problem hiding this comment.
Ok I drop it and replace line 337:
static __maybe_unused void gftp_ssl_keylog_callback(const SSL *ssl, const char *line)by
static void gftp_ssl_keylog_callback(const SSL *ssl, const char *line)
lib/sslcommon.c
Outdated
| /* 'for' loop with wildcard support (*.domain.tld) in subjectAltName */ | ||
| for (j = 0; j < sk_CONF_VALUE_num(val); j++) | ||
| { | ||
| nval = sk_CONF_VALUE_value(val, j); |
There was a problem hiding this comment.
So these first 3 lines are the same as what was there before, and it's showing up as lines added/removed. I suspect it's most likely a difference in tabs or spaces between the two. Can you clean this up so the diff is smaller? The logic of the function in your changes looks good to me.
|
Hi @nbanb : I had time for a more thorough review. Sorry it took me longer than I would have liked this week to get back to you. |
…x version check Adding support of OpenSSL SSLKEYLOGFILE to be able to decrypt FTPS TLSv1.2+ traffic using Diffie Hellman and Elliptic Curves like cipher TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 To create SSLKEYLOGFILE, simply run from your shell : ```bash export SSLKEYLOGFILE=~/gftp-tls.log ``` And launch `gftp`. If you capture traffic with a command like: ```bash sudo tcpdump -nnei any -vvvttttXXX 'host <server_ip> and host <client_ip> and (port 21 or port <passive_port>)' -w ~/gftp.pcap ``` You can pass `gftp-tls.log` and `gftp.pcap` to a software like `wireshark` and you will be able to decrypt the TLS traffic and to see FTP command and reply. Example of live FTPS traffic decryption using `tshark` (`Wireshark` command line tool) in a `tcpdump` style: ```bash sudo setcap CAP_NET_RAW,CAP_NET_ADMIN,CAP_DAC_OVERRIDE+eip /usr/bin/dumpcap tshark -i <network_interface> -n -o tls.keylog_file:~/gftp-tls.log -o tls.desegment_ssl_records:TRUE -o tls.desegment_ssl_application_data:TRUE -t ad -l -f 'host <server_ip> and host <client_ip> and (port 21 or port <passive_port>)' -T fields -e frame.number -e frame.time_relative -e ip.src -e ip.dst -e tcp.srcport -e tcp.dstport -e tcp.flags.str -e tcp.len -e _ws.col.Protocol -e _ws.col.Info ```
|
Hi Brian Thanks for your help and time reviewing the code ! All asked changes had been made:
Also I Last thing, I did update the last commit comment to:
Maybe part of this comment should be added to documentation. Thus writing somewhere (in doc) that only versions of OpenSSL supported by OpenSSL itself can be used and supported by gFTP may be an idea Please let me know if all OK now or if further changes are needed. Thanks and kind regards |
|
Merged. Thank you for your contribution! |


20250414:
First commit add support of TLS validation for wildcard domain names (*.domain.tld) present in certificate subjectAltName field
See 20250414 comments
EDIT 20250417:
The second commit add support for OpenSSL SSLKEYLOGFILE to be able to decrypt TLS1.2+ with elliptic curves (ECDHE_*)
See 20250417 comments