Net-ACME

 view release on metacpan or  search on metacpan

examples/Net_ACME_Example.pm  view on Meta::CPAN

    my ($handle_combination_cr) = @_;

    my $tos_url = Net::ACME::LetsEncrypt->get_terms_of_service();
    print "Look at:$/$/\t$tos_url$/$/… and hit CTRL-C if you DON’T accept these terms.$/";
    <STDIN>;

    #Safe as of 2016
    my $key_size = 2_048;

    my $reg_rsa     = Crypt::OpenSSL::RSA->generate_key($KEY_SIZE);
    my $reg_rsa_pem = $reg_rsa->get_private_key_string();

    #Want a real cert? Then comment this out.
    {
        no warnings 'redefine';
        *Net::ACME::LetsEncrypt::_HOST = \&Net::ACME::LetsEncrypt::STAGING_SERVER;
    }

    my $acme = Net::ACME::LetsEncrypt->new( key => $reg_rsa_pem );

    my $reg = $acme->register();

examples/Net_ACME_Example.pm  view on Meta::CPAN

    my @san_parts = map { "DNS.$_:$domains[$_]" } 0 .. $#domains;

    $req->add_ext(
        Crypt::OpenSSL::PKCS10::NID_subject_alt_name(),
        join( ',', @san_parts ),
    );
    $req->add_ext_final();

    $req->sign();

    return ( $rsa->get_private_key_string(), $req->get_pem_req() );
}

1;

lib/Net/ACME/Crypt/RSA.pm  view on Meta::CPAN

*_encode_b64u = \&MIME::Base64::encode_base64url;

my $_C_O_R_failed;

#$key is PEM or DER
sub sign_RS256 {
    my ($msg, $key) = @_;

    #OpenSSL will do this faster.
    if ( !$_C_O_R_failed && _try_to_load_module('Crypt::OpenSSL::RSA') ) {
        my $rsa = Crypt::OpenSSL::RSA->new_private_key($key);
        $rsa->use_sha256_hash();
        return $rsa->sign($msg);
    }

    #No use in continuing to try.
    $_C_O_R_failed = 1;

#    elsif ( !$_no_openssl_bin ) {
#
#

t/lib/Test/Crypt.pm  view on Meta::CPAN

    my ($key, $message, $signature) = @_;

    confess "No key!" if !$key;

    my $ok;

    #cf. eval_bug.readme
    my $eval_err = $@;

    if ( eval { require Crypt::OpenSSL::RSA } ) {
        my $rsa = Crypt::OpenSSL::RSA->new_private_key($key);
        $rsa->use_sha256_hash();
        $ok = $rsa->verify($message, $signature);
    }
    else {
        my ($mfh, $mpath) = File::Temp::tempfile( CLEANUP => 1 );
        print {$mfh} $message or die $!;
        close $mfh;

        my ($sfh, $spath) = File::Temp::tempfile( CLEANUP => 1 );
        print {$sfh} $signature or die $!;



( run in 0.384 second using v1.01-cache-2.11-cpan-4d50c553e7e )