#!/usr/bin/env perl

##########################################################################
##                                                             
##         FILE: ssl4curl
##        USAGE: Add to your ~/.bashrc or export from command line
##               export `ssl4curl`
##  DESCRIPTION: Download and setup Mozilla certificates for curl SSL/TLS
##
##      OPTIONS:  -h for help
##                -l to list export string
##                -i initialize
## REQUIREMENTS:  perl
##         BUGS:  ---
##        NOTES:  ---
##       AUTHOR:  Zdenek Bohunek (z448), zed448@icloud.com
##      COMPANY:  load.sh laboratory
##      VERSION:  1.0
##      CREATED:  05/25/2016 09:34:33
##     REVISION:  ---
##########################################################################

use warnings;
use strict;

use Getopt::Std;
use Cwd;
use Config;
use open qw<:encoding(UTF-8)>;
use App::ssl4curl qw< get_ca install_ca >;

my( %option, $mozilla_ca_path, $mk_ca_bundle_script ) = ();
getopts('hpi', \%option);

my $CURL_CA_BUNDLE = get_ca();

if(defined $option{p}){ 
    print "export CURL_CA_BUNDLE=$CURL_CA_BUNDLE" if get_ca();
} elsif(defined $option{i}){
    print "initialized\n" if install_ca();
} elsif(defined $option{h}){
    system("perldoc $0");
    die;
} else {
    print "CURL_CA_BUNDLE=$CURL_CA_BUNDLE\n" if get_ca();
}

=head1 NAME 

=over 12

=item ssl4curl

=back

=head1 SYNOPSIS

=over 12

=item Download and setup Mozilla certificates for curl SSL/TLS

=item aka fix for error bellow

curl: (60) SSL certificate problem: unable to get local issuer certificate

=back

=head1 INSTALLATION

=over 12

=item clone repository

git clone https://github.com/z448/ssl4curl

=item initialize from command line as root or use sudo

sudo ssl4curl -i

=back 

=head1 USAGE

=over 12 

- add to ~/.bashrc to check/download and setup certificates on start of every session

C<export `ssl4curl -p`>

- execute on command line to check/download certificates and list export string. You can add output string into your ~/.bashrc in which case certificate setup will be skiped on start of session.

C<ssl4curl>

- print this pod

C<ssl4curl -h>

=back

=cut





