File Coverage

blib/lib/Comodo/DCV.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package Comodo::DCV;
2              
3 2     2   27195 use strict;
  2         3  
  2         47  
4 2     2   6 use warnings;
  2         2  
  2         59  
5              
6 2     2   8 use Digest::MD5 ();
  2         13  
  2         30  
7 2     2   881 use Digest::SHA ();
  2         4765  
  2         250  
8              
9             our $VERSION = 0.03;
10              
11             =pod
12              
13             =encoding utf-8
14              
15             =head1 NAME
16              
17             Comodo::DCV - DCV logic for COMODO SSL APIs
18              
19             =head1 SYNOPSIS
20              
21             use Comodo::DCV;
22              
23             #The following acts on a DER-formatted (i.e., binary) CSR only.
24             my ($filename, $contents) = Comodo::DCV::get_filename_and_contents( $csr_der );
25              
26             =head1 DESCRIPTION
27              
28             This module implements logic that is necessary for HTTP-based validation
29             according to COMODO’s APIs for SSL certificate issuance, as documented
30             at L.
31              
32             You can verify this module’s output by comparing it to that from
33             L.
34              
35             B: This module works on DER-formatted (binary) CSRs. If you need to work with
36             PEM-formatted (text/Base64) CSRs, first convert them via C or similar
37             logic.
38              
39             =cut
40              
41             sub get_filename_and_contents {
42 3     3 0 1028 my ($csr_der) = @_;
43              
44 3 100       25 die 'Call in list context!' if !wantarray;
45              
46 1         11 my $md5_hash = Digest::MD5::md5_hex($csr_der);
47 1         3 $md5_hash =~ tr;
48              
49 1         6 my $filename = "$md5_hash.txt";
50              
51 1         25 my $contents = join(
52             $/,
53             Digest::SHA::sha1_hex($csr_der),
54             'comodoca.com',
55             );
56              
57 1         5 return ( $filename, $contents );
58             }
59              
60             =pod
61              
62             =head1 BUGS
63              
64             Please report to L.
65             Thank you!
66              
67             =head1 AUTHOR
68              
69             Felipe Gasper
70             CPAN ID: FELIPE
71              
72             =head1 COPYRIGHT
73              
74             This program is free software; you can redistribute
75             it and/or modify it under the same terms as Perl itself.
76              
77             The full text of the license can be found in the
78             LICENSE file included with this module.
79              
80             =cut
81              
82             1;