mirror of https://github.com/adamdruppe/arsd.git
Merge pull request #303 from Panke/pre-master-secrets
feat(http2): write pre-master secrets to file
This commit is contained in:
commit
7515fcafae
25
http2.d
25
http2.d
|
@ -2532,6 +2532,7 @@ version(use_openssl) {
|
||||||
SSL_METHOD* function() SSLv3_client_method;
|
SSL_METHOD* function() SSLv3_client_method;
|
||||||
SSL_METHOD* function() TLS_client_method;
|
SSL_METHOD* function() TLS_client_method;
|
||||||
|
|
||||||
|
void function(SSL_CTX*, void function(SSL*, char* line)) SSL_CTX_set_keylog_callback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2629,6 +2630,14 @@ version(use_openssl) {
|
||||||
else throw new Exception("ERR_print_errors_fp not loaded");
|
else throw new Exception("ERR_print_errors_fp not loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern(C)
|
||||||
|
void SSL_CTX_keylog_cb_func(SSL_CTX* ctx, void function(SSL*, char*) func)
|
||||||
|
{
|
||||||
|
if(ossllib.SSL_CTX_set_keylog_callback)
|
||||||
|
ossllib.SSL_CTX_set_keylog_callback(ctx, func);
|
||||||
|
else throw new Exception("SSL_CTX_keylog_cb_func not loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private __gshared void* ossllib_handle;
|
private __gshared void* ossllib_handle;
|
||||||
version(Windows)
|
version(Windows)
|
||||||
|
@ -2741,6 +2750,20 @@ version(use_openssl) {
|
||||||
|
|
||||||
//pragma(lib, "crypto");
|
//pragma(lib, "crypto");
|
||||||
//pragma(lib, "ssl");
|
//pragma(lib, "ssl");
|
||||||
|
extern(C)
|
||||||
|
void write_to_file(SSL* ssl, char* line)
|
||||||
|
{
|
||||||
|
import std.stdio;
|
||||||
|
import std.string;
|
||||||
|
import std.process : environment;
|
||||||
|
string logfile = environment.get("SSLKEYLOGFILE");
|
||||||
|
if (logfile !is null)
|
||||||
|
{
|
||||||
|
auto f = std.stdio.File("/tmp/keyfile", "a+");
|
||||||
|
f.writeln(fromStringz(line));
|
||||||
|
f.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class OpenSslSocket : Socket {
|
class OpenSslSocket : Socket {
|
||||||
private SSL* ssl;
|
private SSL* ssl;
|
||||||
|
@ -2748,7 +2771,7 @@ version(use_openssl) {
|
||||||
private void initSsl(bool verifyPeer, string hostname) {
|
private void initSsl(bool verifyPeer, string hostname) {
|
||||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||||
assert(ctx !is null);
|
assert(ctx !is null);
|
||||||
|
debug SSL_CTX_keylog_cb_func(ctx, &write_to_file);
|
||||||
ssl = SSL_new(ctx);
|
ssl = SSL_new(ctx);
|
||||||
|
|
||||||
if(hostname.length)
|
if(hostname.length)
|
||||||
|
|
Loading…
Reference in New Issue