Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual C, C89 and Win32 Shining Light precompiled fixes #188

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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
Expand Down
47 changes: 32 additions & 15 deletions SSLeay.xs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -2559,9 +2562,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");
Expand Down Expand Up @@ -3784,12 +3788,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)))
Expand Down Expand Up @@ -3910,9 +3915,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;

Expand Down Expand Up @@ -5693,11 +5699,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);
Expand Down Expand Up @@ -5906,7 +5912,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. */
Expand All @@ -5916,6 +5921,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");
Expand All @@ -5929,7 +5938,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);
Expand Down Expand Up @@ -6210,13 +6218,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);
Expand Down Expand Up @@ -6885,10 +6896,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);
Expand Down Expand Up @@ -7088,9 +7100,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");
Expand Down Expand Up @@ -7121,9 +7134,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");
Expand All @@ -7147,7 +7161,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;
Expand All @@ -7156,6 +7170,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);
Expand Down Expand Up @@ -7186,10 +7201,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");
Expand Down Expand Up @@ -7281,11 +7297,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");
Expand Down