Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to properly log traffic keys in openssl using SSL_CTX_set_keylog_callback?

I created this callback function to log the secret key

void SSL_CTX_keylog_cb_func_cb(const SSL *ssl, const char *line){
    FILE  * fp;
    fp = fopen("key_log.log", "w");
    if (fp == NULL)
    {
        printf("Failed to create log file\n");
    }
    fprintf(fp, "%s\n", line);
    fclose(fp);
}

in key_log.log I only get this

CLIENT_TRAFFIC_SECRET_0 af391f5fa21ca10ac61262e4<REDACTED>4

trying to use this log file to decrypt the captured traffic in wireshark does not help and all packets are still encrypted, what am I doing wrong

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

this is how I set the call back function

    SSL_library_init();
    ctx = init_ctx();
    SSL_CTX_set_keylog_callback(ctx, SSL_CTX_keylog_cb_func_cb);

>Solution :

Using "w" mode, the previous contents of the file to open is erased to overwrite.

Use "a" mode to append data to file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading