I would like to extract the session key, master key and premaster key in TLS connection. In my case nginx plays TLS termination. So I want to see those key in nginx side.
Here is my nginx.conf
user nginx;
worker_processes 1;
env SSLKEYLOGFILE=/tmp/premaster.txt;
env LD_PRELOAD=/usr/local/lib/libsslkeylog.so;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
ssl_engine pkcs11;
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
listen 443 ssl;
ssl_protocols TLSv1.2 TLSv1.3;
server_name www.wannacoffee.com wannacoffee.com;
ssl_certificate /etc/ssl/certs/coffeeweb.crt;
ssl_certificate_key "engine:pkcs11:pkcs11:token=mimi;object=coffeekey;type=private;pin-value=1234";
root /var/www/html;
index index.html;
location /small {
root /var/www/html;
}
location /medium {
root /var/www/html;
}
location /encrypt {
proxy_pass http://127.0.0.1:5000;
proxy_redirect http://localhost:5000/ /;
proxy_read_timeout 60s;
# May not need or want to set Host. Should default to the above hostname.
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format ssl_handshake '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$ssl_protocol $ssl_cipher $ssl_session_reused';
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/ssl_handshake.log ssl_handshake;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
At the client sides, I did curl
then cat /tmp/premaster.txt
in server side, but It is empty. I did restart daemon and nginx after add SSLKEYLOGFILE
to configuration.
Please help, thank you.