Skip to content

Commit 1354af4

Browse files
authored
Merge pull request #3 from perl-net-saml2/more-fixes
More fixes for issues with OpenSSL version and threaded perls
2 parents 24b5db6 + ddfd2c2 commit 1354af4

File tree

5 files changed

+30
-51
lines changed

5 files changed

+30
-51
lines changed

.github/workflows/windows-strawberry.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
with:
2525
perl-version: ${{ matrix.perl }}
2626
distribution: strawberry
27+
- name: perl -V
28+
run: perl -V
2729
- name: Install Dependencies
2830
run: cpanm --installdeps .
2931
- name: Build Module

Makefile.PL

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,9 @@ my %args;
1515

1616
my ($major, $minor, $patch) = openssl_version();
1717
print "Installed OpenSSL: $major.$minor.$patch\n";
18-
if ($^O ne 'MSWin32' and my $prefix = `brew --prefix --installed openssl\@1.1 2>@{[File::Spec->devnull]}`) {
19-
chomp $prefix;
20-
$args{INC} = "-I$prefix/include";
21-
$args{LIBS} = ["-L$prefix/lib -lcrypto -lssl"];
22-
} else {
23-
$args{INC} = '-I/usr/local/opt/openssl/include -I/usr/local/include/openssl -I/usr/include/openssl -I/usr/local/include/ssl -I/usr/local/ssl/include';
24-
$args{LIBS} = ['-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/lib -L/usr/local/ssl/lib -lcrypto -lssl'];
25-
}
2618

27-
if ($^O eq 'MSWin32') {
28-
if (my $libs = `pkg-config --libs libcrypto 2>nul`) {
29-
# strawberry perl has pkg-config
30-
$args{LIBS} = [ $libs ];
31-
} else {
32-
$args{LIBS} = ['-llibeay32'] if $Config{cc} =~ /cl/; # msvc with ActivePerl
33-
$args{LIBS} = ['-leay32'] if $Config{gccversion}; # gcc
34-
}
35-
}
19+
$args{INC} = openssl_inc_paths();
20+
$args{LIBS} = [openssl_lib_paths() . ' -lssl -lcrypto'];
3621

3722
my $cc_option_flags = $major ge 3 ? ' -DOPENSSL_API_COMPAT=30000' : ' -DOPENSSL_API_COMPAT=10100';
3823

@@ -43,7 +28,10 @@ if ($Config::Config{cc} =~ /gcc/i) {
4328
}
4429

4530
if ($Config{gccversion} =~ /llvm/i) {
46-
if ( $^O eq 'darwin' && $Config{gccversion} =~ /LLVM 12.0.5/) {
31+
if ( $^O eq 'darwin' && (
32+
$Config{gccversion} =~ /LLVM 1[2-9].\d.[5-9]/ ||
33+
$Config{gccversion} =~ /LLVM 1[3-9]/ ))
34+
{
4735
$cc_option_flags .= ' -Wno-deprecated-declarations -Wno-compound-token-split-by-macro';
4836
} else {
4937
$cc_option_flags .= ' -Wno-deprecated-declarations';
@@ -82,7 +70,7 @@ my %WriteMakefileArgs = (
8270
"File::Slurper" => "0.012",
8371
"File::Which" => 0
8472
},
85-
"VERSION" => "0.05",
73+
"VERSION" => "0.06",
8674
"test" => {
8775
"TESTS" => "t/*.t"
8876
}

SignCSR.xs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int set_cert_times(X509 *x, const char *startdate, const char *enddate,
8888
if (X509_time_adj_ex(X509_getm_notAfter(x), days, 0, NULL)
8989
== NULL)
9090
return 0;
91-
#if OPENSSL_API_COMPAT >= 10100
91+
#if OPENSSL_API_COMPAT >= 10101
9292
} else if (!ASN1_TIME_set_string_X509(X509_getm_notAfter(x), enddate)) {
9393
#else
9494
} else if (!ASN1_TIME_set_string(X509_getm_notAfter(x), enddate)) {
@@ -195,7 +195,7 @@ void croakSsl(char* p_file, int p_line)
195195
croak("%s:%d: OpenSSL error: %s", p_file, p_line, errorReason);
196196
}
197197

198-
SV* extractBioString(BIO* p_stringBio)
198+
SV* extractBioString(pTHX_ BIO* p_stringBio)
199199
{
200200
SV* sv;
201201
BUF_MEM* bptr;
@@ -437,9 +437,8 @@ IV set_digest(self, SV* digest)
437437
HV * self;
438438

439439
CODE:
440-
IV ret = 0;
441-
char * digestname = NULL;
442-
IV digestname_length;
440+
const char * digestname = NULL;
441+
STRLEN digestname_length;
443442

444443
RETVAL = 0;
445444
// Get digestname parameter - verify that it is valid
@@ -449,16 +448,17 @@ IV set_digest(self, SV* digest)
449448
EVP_MD * md = NULL;
450449
#endif
451450
if (digest != NULL) {
452-
digestname = (char*) SvPV(digest, digestname_length);
451+
digestname = (const char*) SvPV(digest, digestname_length);
453452
//printf("Digest Name: %s\n", digestname);
454453
md = (EVP_MD *)EVP_get_digestbyname(digestname);
455454
}
456455

457-
if (md != NULL)
456+
if (md != NULL) {
458457
if((hv_store(self, "digest", 6, newRV_inc(digest), 0)) == NULL)
459458
RETVAL = 0;
460459
else
461460
RETVAL = 1;
461+
}
462462

463463
OUTPUT:
464464

@@ -528,7 +528,6 @@ IV set_days(self, IV days)
528528
HV * self;
529529

530530
CODE:
531-
IV ret = 0;
532531

533532
if((hv_store(self, "days", 4, newSViv(days), 0)) == NULL)
534533
RETVAL = 0;
@@ -557,7 +556,7 @@ SV * sign(self, request_SV, sigopts)
557556
STRLEN request_length;
558557
unsigned char* request;
559558
BIO *csrbio;
560-
char * digestname;
559+
const char * digestname;
561560
STRLEN digestname_length;
562561
IV days;
563562
SV * digest = NULL;
@@ -578,6 +577,9 @@ SV * sign(self, request_SV, sigopts)
578577
if (SvIOKp(*svp)) {
579578
days = SvIV(*svp);
580579
}
580+
else {
581+
days = 365;
582+
}
581583

582584
if (hv_exists(self, "digest", strlen("digest"))) {
583585
svp = hv_fetch(self, "digest", strlen("digest"), 0);
@@ -705,12 +707,11 @@ SV * sign(self, request_SV, sigopts)
705707
EVP_MD * md = NULL;
706708
#endif
707709
if (digest != NULL) {
708-
digestname = (unsigned char*) SvPV(digest, digestname_length);
709-
//printf("Digest Name: %s\n", digestname);
710+
digestname = (const char*) SvPV(digest, digestname_length);
710711
md = (EVP_MD *)EVP_get_digestbyname(digestname);
711712
}
712713
if (md != NULL)
713-
digestname = (char *) digestname;
714+
digestname = (const char *) digestname;
714715
else
715716
digestname = NULL;
716717

@@ -743,7 +744,7 @@ SV * sign(self, request_SV, sigopts)
743744
if (!i)
744745
croak("unable to output certificate data\n");
745746

746-
RETVAL = extractBioString(out);
747+
RETVAL = extractBioString(aTHX_ out);
747748

748749
OUTPUT:
749750

lib/Crypt/OpenSSL/SignCSR.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use warnings;
77

88
require Exporter;
99

10-
our $VERSION = "0.05";
10+
our $VERSION = "0.06";
1111

1212
our @ISA = qw(Exporter);
1313

maint/Makefile_header.PL

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,9 @@ my %args;
55

66
my ($major, $minor, $patch) = openssl_version();
77
print "Installed OpenSSL: $major.$minor.$patch\n";
8-
if ($^O ne 'MSWin32' and my $prefix = `brew --prefix --installed openssl\@1.1 2>@{[File::Spec->devnull]}`) {
9-
chomp $prefix;
10-
$args{INC} = "-I$prefix/include";
11-
$args{LIBS} = ["-L$prefix/lib -lcrypto -lssl"];
12-
} else {
13-
$args{INC} = '-I/usr/local/opt/openssl/include -I/usr/local/include/openssl -I/usr/include/openssl -I/usr/local/include/ssl -I/usr/local/ssl/include';
14-
$args{LIBS} = ['-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/lib -L/usr/local/ssl/lib -lcrypto -lssl'];
15-
}
168

17-
if ($^O eq 'MSWin32') {
18-
if (my $libs = `pkg-config --libs libcrypto 2>nul`) {
19-
# strawberry perl has pkg-config
20-
$args{LIBS} = [ $libs ];
21-
} else {
22-
$args{LIBS} = ['-llibeay32'] if $Config{cc} =~ /cl/; # msvc with ActivePerl
23-
$args{LIBS} = ['-leay32'] if $Config{gccversion}; # gcc
24-
}
25-
}
9+
$args{INC} = openssl_inc_paths();
10+
$args{LIBS} = [openssl_lib_paths() . ' -lssl -lcrypto'];
2611

2712
my $cc_option_flags = $major ge 3 ? ' -DOPENSSL_API_COMPAT=30000' : ' -DOPENSSL_API_COMPAT=10100';
2813

@@ -33,7 +18,10 @@ if ($Config::Config{cc} =~ /gcc/i) {
3318
}
3419

3520
if ($Config{gccversion} =~ /llvm/i) {
36-
if ( $^O eq 'darwin' && $Config{gccversion} =~ /LLVM 12.0.5/) {
21+
if ( $^O eq 'darwin' && (
22+
$Config{gccversion} =~ /LLVM 1[2-9].\d.[5-9]/ ||
23+
$Config{gccversion} =~ /LLVM 1[3-9]/ ))
24+
{
3725
$cc_option_flags .= ' -Wno-deprecated-declarations -Wno-compound-token-split-by-macro';
3826
} else {
3927
$cc_option_flags .= ' -Wno-deprecated-declarations';

0 commit comments

Comments
 (0)