diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 05324ec7fcb..d3f061cc500 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1090,17 +1090,11 @@ Handle Connection::GetPeerCertificate(const Arguments& args) { } (void) BIO_reset(bio); - char buf[256]; - bio = NULL; - int index = X509_get_ext_by_NID(peer_cert, NID_subject_alt_name, -1); if (index >= 0) { X509_EXTENSION* ext; - BUF_MEM* mem; int rv; - bio = BIO_new(BIO_s_mem()); - ext = X509_get_ext(peer_cert, index); assert(ext != NULL); @@ -1110,29 +1104,23 @@ Handle Connection::GetPeerCertificate(const Arguments& args) { BIO_get_mem_ptr(bio, &mem); info->Set(subjectaltname_symbol, String::New(mem->data, mem->length)); - BIO_free(bio); + (void) BIO_reset(bio); } - (void) BIO_reset(bio); EVP_PKEY *pkey = NULL; RSA *rsa = NULL; if( NULL != (pkey = X509_get_pubkey(peer_cert)) && NULL != (rsa = EVP_PKEY_get1_RSA(pkey)) ) { - bio = BIO_new(BIO_s_mem()); BN_print(bio, rsa->n); - memset(buf, 0, sizeof(buf)); - BIO_read(bio, buf, sizeof(buf) - 1); - info->Set(modulus_symbol, String::New(buf) ); - BIO_free(bio); + BIO_get_mem_ptr(bio, &mem); + info->Set(modulus_symbol, String::New(mem->data, mem->length) ); + (void) BIO_reset(bio); - bio = BIO_new(BIO_s_mem()); BN_print(bio, rsa->e); - memset(buf, 0, sizeof(buf)); - BIO_read(bio, buf, sizeof(buf) - 1); - info->Set(exponent_symbol, String::New(buf) ); - BIO_free(bio); + BIO_get_mem_ptr(bio, &mem); + info->Set(exponent_symbol, String::New(mem->data, mem->length) ); + (void) BIO_reset(bio); } - (void) BIO_reset(bio); ASN1_TIME_print(bio, X509_get_notBefore(peer_cert)); BIO_get_mem_ptr(bio, &mem); diff --git a/test/simple/test-https-foafssl.js b/test/simple/test-https-foafssl.js index 52dc852fdf5..73ec5653215 100644 --- a/test/simple/test-https-foafssl.js +++ b/test/simple/test-https-foafssl.js @@ -80,6 +80,9 @@ process.on('exit', function () { assert.equal(modulus, 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC\ 3A5519F349CD9B9C40BE436D0AA823A94147E26C89248ADA2BE3DD4D34E8C28964694B2047D217\ B4F1299371EA93A83C89AB9440724131E65F2B0161DE9560CDE9C13455552B2F49CF0FB00D8D77\ -532324913F6F80FF29D0A131D29DB06AFF8BE191B7920D'); +532324913F6F80FF29D0A131D29DB06AFF8BE191B7920DC2DAE1C26EA82A47847A10391EF3BF6A\ +ABB3CC40FF82100B03A4F0FF1809278E4DDFDA7DE954ED56DC7AD9A47EEBC37D771A366FC60A5B\ +CB72373BEC180649B3EFA0E9092707210B41B90032BB18BC91F2046EBDAF1191F4A4E26D71879C\ +4C7867B62FCD508E8CE66E82D128A71E915809FCF44E8DE774067F1DE5D70B9C03687'); assert.equal(exponent, '10001'); });