mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Merge remote-tracking branch 'origin/pr/538'
Conflicts: ext/puma_http11/mini_ssl.c
This commit is contained in:
commit
827a43ce81
1 changed files with 51 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <rubyio.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
typedef struct {
|
||||
|
@ -36,6 +37,42 @@ ms_conn* engine_alloc(VALUE klass, VALUE* obj) {
|
|||
return conn;
|
||||
}
|
||||
|
||||
DH *get_dh1024() {
|
||||
/* `openssl dhparam 1024 -C`
|
||||
* -----BEGIN DH PARAMETERS-----
|
||||
* MIGHAoGBALPwcEv0OstmQCZdfHw0N5r+07lmXMxkpQacy1blwj0LUqC+Divp6pBk
|
||||
* usTJ9W2/dOYr1X7zi6yXNLp4oLzc/31PUL3D9q8CpGS7vPz5gijKSw9BwCTT5z9+
|
||||
* KF9v46qw8XqT5HHV87sWFlGQcVFq+pEkA2kPikkKZ/X/CCcpCAV7AgEC
|
||||
* -----END DH PARAMETERS-----
|
||||
*/
|
||||
static unsigned char dh1024_p[] = {
|
||||
0xB3,0xF0,0x70,0x4B,0xF4,0x3A,0xCB,0x66,0x40,0x26,0x5D,0x7C,
|
||||
0x7C,0x34,0x37,0x9A,0xFE,0xD3,0xB9,0x66,0x5C,0xCC,0x64,0xA5,
|
||||
0x06,0x9C,0xCB,0x56,0xE5,0xC2,0x3D,0x0B,0x52,0xA0,0xBE,0x0E,
|
||||
0x2B,0xE9,0xEA,0x90,0x64,0xBA,0xC4,0xC9,0xF5,0x6D,0xBF,0x74,
|
||||
0xE6,0x2B,0xD5,0x7E,0xF3,0x8B,0xAC,0x97,0x34,0xBA,0x78,0xA0,
|
||||
0xBC,0xDC,0xFF,0x7D,0x4F,0x50,0xBD,0xC3,0xF6,0xAF,0x02,0xA4,
|
||||
0x64,0xBB,0xBC,0xFC,0xF9,0x82,0x28,0xCA,0x4B,0x0F,0x41,0xC0,
|
||||
0x24,0xD3,0xE7,0x3F,0x7E,0x28,0x5F,0x6F,0xE3,0xAA,0xB0,0xF1,
|
||||
0x7A,0x93,0xE4,0x71,0xD5,0xF3,0xBB,0x16,0x16,0x51,0x90,0x71,
|
||||
0x51,0x6A,0xFA,0x91,0x24,0x03,0x69,0x0F,0x8A,0x49,0x0A,0x67,
|
||||
0xF5,0xFF,0x08,0x27,0x29,0x08,0x05,0x7B
|
||||
};
|
||||
static unsigned char dh1024_g[] = { 0x02 };
|
||||
|
||||
DH *dh;
|
||||
dh = DH_new();
|
||||
dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
|
||||
dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
|
||||
|
||||
if ((dh->p == NULL) || (dh->g == NULL)) {
|
||||
DH_free(dh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dh;
|
||||
}
|
||||
|
||||
VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
|
||||
VALUE obj;
|
||||
SSL_CTX* ctx;
|
||||
|
@ -54,7 +91,20 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
|
|||
|
||||
SSL_CTX_use_certificate_file(ctx, RSTRING_PTR(cert), SSL_FILETYPE_PEM);
|
||||
SSL_CTX_use_PrivateKey_file(ctx, RSTRING_PTR(key), SSL_FILETYPE_PEM);
|
||||
/* SSL_CTX_set_options(ctx, SSL_OP_SINGLE_DH_USE); */
|
||||
|
||||
SSL_CTX_set_options(ctx, SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_NO_SSLv2 | SSL_OP_SINGLE_DH_USE | SSL_OP_SINGLE_ECDH_USE);
|
||||
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
|
||||
|
||||
SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL@STRENGTH");
|
||||
|
||||
DH *dh = get_dh1024();
|
||||
SSL_CTX_set_tmp_dh(ctx, dh);
|
||||
|
||||
EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_secp521r1);
|
||||
if (ecdh) {
|
||||
SSL_CTX_set_tmp_ecdh(ctx, ecdh);
|
||||
EC_KEY_free(ecdh);
|
||||
}
|
||||
|
||||
ssl = SSL_new(ctx);
|
||||
conn->ssl = ssl;
|
||||
|
|
Loading…
Add table
Reference in a new issue