From 9c53a67604bee11a68215f35979cbc5428db63f9 Mon Sep 17 00:00:00 2001 From: bulk88 Date: Mon, 3 Aug 2020 13:42:36 -0400 Subject: [PATCH 1/3] newer Shining Light Win32 precompiled binaries install in "Program Files" -no need to set OPENSSL_PREFIX in majority of cases now with Shining Light --- Makefile.PL | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.PL b/Makefile.PL index cbfc55f8..de5ea66c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -263,6 +263,8 @@ sub find_openssl_prefix { '/usr/sfw/bin/openssl' => '/usr/sfw', # Open Solaris 'C:\OpenSSL\bin\openssl.exe' => 'C:\OpenSSL', 'C:\OpenSSL-Win32\bin\openssl.exe' => 'C:\OpenSSL-Win32', + 'C:\Program Files\OpenSSL\bin\openssl.exe' => 'C:\Program Files\OpenSSL', + 'C:\Program Files\OpenSSL-Win32\bin\openssl.exe' => 'C:\Program Files\OpenSSL-Win32', $Config{prefix} . '\bin\openssl.exe' => $Config{prefix}, # strawberry perl $Config{prefix} . '\..\c\bin\openssl.exe' => $Config{prefix} . '\..\c', # strawberry perl '/sslexe/openssl.exe' => '/sslroot', # VMS, openssl.org From 4ecea059353d0681fac0242c95c22cd8a973501f Mon Sep 17 00:00:00 2001 From: bulk88 Date: Mon, 3 Aug 2020 14:16:27 -0400 Subject: [PATCH 2/3] C89/Visual C compatibility, no code before decl --- SSLeay.xs | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/SSLeay.xs b/SSLeay.xs index c88855a1..fa805ef6 100644 --- a/SSLeay.xs +++ b/SSLeay.xs @@ -2559,9 +2559,10 @@ SSL_verify_client_post_handshake(SSL *ssl) void i2d_SSL_SESSION(sess) SSL_SESSION * sess - PPCODE: + PREINIT: STRLEN len; unsigned char *pc,*pi; + PPCODE: if (!(len = i2d_SSL_SESSION(sess,NULL))) croak("invalid SSL_SESSION"); Newx(pc,len,unsigned char); if (!pc) croak("out of memory"); @@ -3784,12 +3785,13 @@ X509_get_fingerprint(cert,type) void X509_get_subjectAltNames(cert) X509 * cert - PPCODE: + PREINIT: int i, j, count = 0; X509_EXTENSION *subjAltNameExt = NULL; STACK_OF(GENERAL_NAME) *subjAltNameDNs = NULL; GENERAL_NAME *subjAltNameDN = NULL; int num_gnames; + PPCODE: if ( (i = X509_get_ext_by_NID(cert, NID_subject_alt_name, -1)) >= 0 && (subjAltNameExt = X509_get_ext(cert, i)) && (subjAltNameDNs = X509V3_EXT_d2i(subjAltNameExt))) @@ -3910,9 +3912,10 @@ P_X509_get_crl_distribution_points(cert) void P_X509_get_ocsp_uri(cert) X509 * cert - PPCODE: + PREINIT: AUTHORITY_INFO_ACCESS *info; int i; + PPCODE: info = X509_get_ext_d2i(cert, NID_info_access, NULL, NULL); if (!info) XSRETURN_UNDEF; @@ -5693,11 +5696,11 @@ EVP_PKEY_assign_EC_KEY(pkey,key) EC_KEY * EC_KEY_generate_key(curve) SV *curve; - CODE: + PREINIT: EC_GROUP *group = NULL; EC_KEY *eckey = NULL; int nid; - + CODE: RETVAL = 0; if (SvIOK(curve)) { nid = SvIV(curve); @@ -5906,7 +5909,6 @@ RSA_generate_key(bits,ee,perl_cb=&PL_sv_undef,perl_data=&PL_sv_undef) SV* perl_data PREINIT: simple_cb_data_t* cb_data = NULL; - CODE: /* openssl 0.9.8 deprecated RSA_generate_key. */ /* This equivalent was contributed by Brian Fraser for Android, */ /* but was not portable to old OpenSSLs where RSA_generate_key_ex is not available. */ @@ -5916,6 +5918,10 @@ RSA_generate_key(bits,ee,perl_cb=&PL_sv_undef,perl_data=&PL_sv_undef) int rc; RSA * ret; BIGNUM *e; +#if (OPENSSL_VERSION_NUMBER >= 0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)) || (LIBRESSL_VERSION_NUMBER >= 0x2070000fL) + BN_GENCB *new_cb; +#endif + CODE: e = BN_new(); if(!e) croak("Net::SSLeay: RSA_generate_key perl function could not create BN structure.\n"); @@ -5929,7 +5935,6 @@ RSA_generate_key(bits,ee,perl_cb=&PL_sv_undef,perl_data=&PL_sv_undef) croak("Net::SSLeay: RSA_generate_key perl function could not create RSA structure.\n"); } #if (OPENSSL_VERSION_NUMBER >= 0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)) || (LIBRESSL_VERSION_NUMBER >= 0x2070000fL) - BN_GENCB *new_cb; new_cb = BN_GENCB_new(); if(!new_cb) { simple_cb_data_free(cb_data); @@ -6210,13 +6215,16 @@ SSL_get_server_random(s) int SSL_get_keyblock_size(s) SSL * s - CODE: + PREINIT: #if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)) || (LIBRESSL_VERSION_NUMBER >= 0x2070000fL) const SSL_CIPHER *ssl_cipher; int cipher = NID_undef, digest = NID_undef, mac_secret_size = 0; const EVP_CIPHER *c = NULL; const EVP_MD *h = NULL; +#endif + CODE: +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)) || (LIBRESSL_VERSION_NUMBER >= 0x2070000fL) ssl_cipher = SSL_get_current_cipher(s); if (ssl_cipher) cipher = SSL_CIPHER_get_cipher_nid(ssl_cipher); @@ -6885,10 +6893,11 @@ P_X509_get_pubkey_alg(x) void X509_get_X509_PUBKEY(x) const X509 *x - PPCODE: + PREINIT: X509_PUBKEY *pkey; STRLEN len; unsigned char *pc, *pi; + PPCODE: if (!(pkey = X509_get_X509_PUBKEY(x))) croak("invalid certificate"); if (!(len = i2d_X509_PUBKEY(pkey, NULL))) croak("invalid certificate public key"); Newx(pc,len,unsigned char); @@ -7088,9 +7097,10 @@ d2i_OCSP_RESPONSE(pv) void i2d_OCSP_RESPONSE(r) OCSP_RESPONSE * r - PPCODE: + PREINIT: STRLEN len; unsigned char *pc,*pi; + PPCODE: if (!(len = i2d_OCSP_RESPONSE(r,NULL))) croak("invalid OCSP response"); Newx(pc,len,unsigned char); if (!pc) croak("out of memory"); @@ -7121,9 +7131,10 @@ d2i_OCSP_REQUEST(pv) void i2d_OCSP_REQUEST(r) OCSP_REQUEST * r - PPCODE: + PREINIT: STRLEN len; unsigned char *pc,*pi; + PPCODE: if (!(len = i2d_OCSP_REQUEST(r,NULL))) croak("invalid OCSP request"); Newx(pc,len,unsigned char); if (!pc) croak("out of memory"); @@ -7147,7 +7158,7 @@ OCSP_response_status(OCSP_RESPONSE *r) void SSL_OCSP_cert2ids(ssl,...) SSL *ssl - PPCODE: +PREINIT: SSL_CTX *ctx; X509_STORE *store; STACK_OF(X509) *chain; @@ -7156,6 +7167,7 @@ SSL_OCSP_cert2ids(ssl,...) int i; STRLEN len; unsigned char *pi; + PPCODE: if (!ssl) croak("not a SSL object"); ctx = SSL_get_SSL_CTX(ssl); @@ -7186,10 +7198,11 @@ SSL_OCSP_cert2ids(ssl,...) OCSP_REQUEST * OCSP_ids2req(...) - CODE: + PREINIT: OCSP_REQUEST *req; OCSP_CERTID *id; int i; + CODE: req = OCSP_REQUEST_new(); if (!req) croak("out of memory"); @@ -7281,11 +7294,12 @@ SSL_OCSP_response_verify(ssl,rsp,svreq=NULL,flags=0) void OCSP_response_results(rsp,...) OCSP_RESPONSE *rsp - PPCODE: + PREINIT: OCSP_BASICRESP *bsr; int i,want_array; time_t nextupd = 0; int getall,sksn; + PPCODE: bsr = OCSP_response_get1_basic(rsp); if (!bsr) croak("invalid OCSP response"); From 7dfd72a6b2a18d27d48e5d627fa8c946e89c3a27 Mon Sep 17 00:00:00 2001 From: bulk88 Date: Mon, 3 Aug 2020 19:24:13 -0400 Subject: [PATCH 3/3] fix Win32 .lib/.a search loop fails to stop path search once file found -dates to day 1 commit cb98af3caf3b63d7125352aa13d18748ab20ee3a Fixed some compiler warnings. Courtesy kmx. Fixed a problem with Win32 detection. Courtesy kmx. git-svn-id: r334 Committer: Mike McCauley 2012-04-02 04:38:39 ----------------- this caused ----------------- C:\sources\p5-net-ssleay>perl Makefile.PL Do you want to run external tests? These tests *will* *fail* if you do not have network connectivity. [n] y *** Found OpenSSL-1.1.1g installed in C:\Program Files\OpenSSL-Win32 *** Be sure to use the same compiler and options to compile your OpenSSL, perl, and Net::SSLeay. Mixing and matching compilers is not supported. Warning (mostly harmless): No library found for -llibeay32 Warning (mostly harmless): No library found for -lssleay32 Generating a gmake-style Makefile Writing Makefile for Net::SSLeay ------------------- With Shining Light precompiled OpenSSL and eventual there is a link failure since the lib file paths dont exist that are given to EUMM and EUMM eventually puts in MKF then fed to link.exe cmd line, since the $dir loop kept spinning and push new paths into %opts even though in an earlier iteration the .lib file was found on disk -fix a CC warning too about redefinition, perl core provides this flag automatic nowadays if the VC version is new enough to need this --- Makefile.PL | 4 ++-- SSLeay.xs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index de5ea66c..7aea6b64 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -168,14 +168,14 @@ EOM # Library names depend on the compiler @pairs = (['eay32','ssl32'],['crypto.dll','ssl.dll'],['crypto','ssl']) if $Config{cc} =~ /gcc/; @pairs = (['libeay32','ssleay32'],['libeay32MD','ssleay32MD'],['libeay32MT','ssleay32MT'],['libcrypto','libssl'],['crypto','ssl']) if $Config{cc} =~ /cl/; - for my $dir (@{$opts->{lib_paths}}) { + FOUND: for my $dir (@{$opts->{lib_paths}}) { for my $p (@pairs) { $found = 1 if ($Config{cc} =~ /gcc/ && -f "$dir/lib$p->[0].a" && -f "$dir/lib$p->[1].a"); $found = 1 if ($Config{cc} =~ /cl/ && -f "$dir/$p->[0].lib" && -f "$dir/$p->[1].lib"); if ($found) { $opts->{lib_links} = [$p->[0], $p->[1], 'crypt32']; # Some systems need this system lib crypt32 too $opts->{lib_paths} = [$dir]; - last; + last FOUND; } } } diff --git a/SSLeay.xs b/SSLeay.xs index fa805ef6..c6b94621 100644 --- a/SSLeay.xs +++ b/SSLeay.xs @@ -132,7 +132,10 @@ */ /* Prevent warnings about strncpy from Windows compilers */ -#define _CRT_SECURE_NO_DEPRECATE + +#ifndef _CRT_SECURE_NO_DEPRECATE +# define _CRT_SECURE_NO_DEPRECATE +#endif #ifdef __cplusplus extern "C" {