| 1 | package Comodo::DCV; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Digest::MD5 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Digest::SHA (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | our $VERSION = 0.04; | |||||||||
| 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<http://secure.comodo.net/api/pdf/latest/Domain%20Control%20Validation.pdf>. | ||||||||||
| 31 | |||||||||||
| 32 | You can verify this module’s output by comparing it to that from | ||||||||||
| 33 | L<https://secure.comodo.net/utilities/decodeCSR.html>. | ||||||||||
| 34 | |||||||||||
| 35 | B<NOTE>: 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<Crypt::Format> or similar | ||||||||||
| 37 | logic. | ||||||||||
| 38 | |||||||||||
| 39 | =head1 BREAKING CHANGE: 20 JULY 2017 UPDATE | ||||||||||
| 40 | |||||||||||
| 41 | As of 20 July 2017, Comodo will no longer look for SHA-1 hashes in DCV files; | ||||||||||
| 42 | the new format is to use SHA-256 hashes. There is also a change of path for | ||||||||||
| 43 | the DCV check, from F<$document_root/$MD5.txt> to | ||||||||||
| 44 | F<$document_root/.well-known/pki-validation/$MD5.txt>. Any services that might | ||||||||||
| 45 | interact with Comodo’s DCV thus need to stop using the old logic and start | ||||||||||
| 46 | using the new. | ||||||||||
| 47 | |||||||||||
| 48 | Comodo has their new logic is in place as of 10 July 2017. | ||||||||||
| 49 | |||||||||||
| 50 | Note that this means you’ll need to ensure that | ||||||||||
| 51 | F<$document_root/.well-known/pki-validation> exists. That’s something that | ||||||||||
| 52 | this module will B<NOT> do for you. | ||||||||||
| 53 | |||||||||||
| 54 | =cut | ||||||||||
| 55 | |||||||||||
| 56 | 3 | ▶ | sub get_filename_and_contents { | ||||||||
|
Subroutine
get_filename_and_contents: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 57 | 3 | my ($csr_der) = @_; | |||||||||
| 58 | |||||||||||
| 59 | 3 | ▶ | die 'Call in list context!' if !wantarray; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | |||||||||||
| 61 | 1 | my $md5_hash = Digest::MD5::md5_hex($csr_der); | |||||||||
| 62 | 1 | $md5_hash =~ tr<a-f><A-F>; | |||||||||
| 63 | |||||||||||
| 64 | 1 | my $filename = "$md5_hash.txt"; | |||||||||
| 65 | |||||||||||
| 66 | 1 | my $contents = join( | |||||||||
| 67 | $/, | ||||||||||
| 68 | Digest::SHA::sha256_hex($csr_der), | ||||||||||
| 69 | 'comodoca.com', | ||||||||||
| 70 | ); | ||||||||||
| 71 | |||||||||||
| 72 | 1 | return ( $filename, $contents ); | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | =pod | ||||||||||
| 76 | |||||||||||
| 77 | =head1 BUGS | ||||||||||
| 78 | |||||||||||
| 79 | Please report to L<https://github.com/FGasper/p5-Comodo-DCV/issues>. | ||||||||||
| 80 | Thank you! | ||||||||||
| 81 | |||||||||||
| 82 | =head1 AUTHOR | ||||||||||
| 83 | |||||||||||
| 84 | Felipe Gasper | ||||||||||
| 85 | CPAN ID: FELIPE | ||||||||||
| 86 | |||||||||||
| 87 | =head1 COPYRIGHT | ||||||||||
| 88 | |||||||||||
| 89 | This program is free software; you can redistribute | ||||||||||
| 90 | it and/or modify it under the same terms as Perl itself. | ||||||||||
| 91 | |||||||||||
| 92 | The full text of the license can be found in the | ||||||||||
| 93 | LICENSE file included with this module. | ||||||||||
| 94 | |||||||||||
| 95 | =cut | ||||||||||
| 96 | |||||||||||
| 97 | 2 | 1; | |||||||||