-# set SSL/TLS options
-$SSL{SSL_verify_mode} = $ENV{SSLVERIFY} if defined($ENV{SSLVERIFY});
-foreach my $opt (qw(
- SSL_version
- SSL_cipher_list
- SSL_verify_mode
- SSL_ca_path
- SSL_ca_file)
-) {
- my $env = uc($opt);
- $env =~ s/_//g;
- $SSL{$opt} = $ENV{$env} if defined($ENV{$env});
-}
-
-if ($SSL{SSL_verify_mode}) {
- &search_ca;
- unless ($SSL{SSL_ca_path} or $SSL{SSL_ca_file}) {
- die "$0: \$SSLVERIFYMODE, but not valid \$SSLCAPATH or \$SSLCAFILE\n";
- }
-} elsif (defined($SSL{SSL_verify_mode})) {
- # user has set SSLVERIFY=0 !
-} else {
- &search_ca;
- $SSL{SSL_verify_mode} = 1 if $SSL{SSL_ca_path} or $SSL{SSL_ca_file};
-}
-
-sub search_ca {
- local $_;
- return if $SSL{SSL_ca_file} or $SSL{SSL_ca_path};
- foreach (qw(/etc/ssl/certs/ca-certificates.crt)) {
- if (-f) {
- $SSL{SSL_ca_file} = $_;
- return;
- }
- }
- foreach (qw(/etc/ssl/certs /etc/pki/tls/certs)) {
- if (-f) {
- $SSL{SSL_ca_path} = $_;
- return;
- }
- }
-}