Neverbleed OpenSSL / LibreSS 特权分离引擎 项目简介
Neverbleed 是 OpenSSL 引擎,它可以在一个独立的进程中运行 RSA 私钥操作,从而最大程度上减少类似心脏出血这种漏洞所带来的泄密风险。此引擎可同时在 OpenSSL 和 LibreSSL 现有版本下工作,并且不怎么需要修改源代码。示例代码: neverbleed_t nb;
char errbuf[NEVERBLEED_ERRBUF_SIZE];
/* initialize the OpenSSL library and the neverbleed engine */
SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();
if (neverbleed_init(&nb, errbuf) != 0) {
fprintf(stderr, "neverbleed_init failed: %s\n", errbuf);
...
}
...
/* load certificate chain and private key */
if (SSL_CTX_use_certificate_chain_file(ssl_ctx, certchain_fn) != 1) {
fprintf(stderr, "failed to load certificate chain file:%s\n", certchain_fn);
...
}
if (neverbleed_load_private_key_file(&nb, ctx, privkey_fn, errbuf) != 1) {
fprintf(stderr, "failed to load private key from file:%s:%s\n", privkey_fn, errbuf);
...
}
char errbuf[NEVERBLEED_ERRBUF_SIZE];
/* initialize the OpenSSL library and the neverbleed engine */
SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();
if (neverbleed_init(&nb, errbuf) != 0) {
fprintf(stderr, "neverbleed_init failed: %s\n", errbuf);
...
}
...
/* load certificate chain and private key */
if (SSL_CTX_use_certificate_chain_file(ssl_ctx, certchain_fn) != 1) {
fprintf(stderr, "failed to load certificate chain file:%s\n", certchain_fn);
...
}
if (neverbleed_load_private_key_file(&nb, ctx, privkey_fn, errbuf) != 1) {
fprintf(stderr, "failed to load private key from file:%s:%s\n", privkey_fn, errbuf);
...
}