💾 Archived View for thrig.me › tech › ssl › certid.pl captured on 2024-05-10 at 12:40:12.
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
#!/usr/bin/env perl # certid.pl - calculate certificate fingerprints from both the whole # certificate (typical) and also just the Subject Public Key Info # section (atypical, but used by amfora and other gemini clients) use 5.12.0; use warnings; use Digest::SHA 'sha256_hex'; use Net::SSLeay; my $file = shift // die "Usage: certid.pl certificate-file\n"; my $bio = Net::SSLeay::BIO_new_file( $file, 'r' ); my $cert = Net::SSLeay::PEM_read_bio_X509($bio); # typical say Net::SSLeay::X509_get_fingerprint( $cert, 'sha256' ); # how amfora does it my $pubkey = Net::SSLeay::X509_get_X509_PUBKEY($cert); say uc( sha256_hex( $pubkey ) );