|
NAMEModule::Signature - Module signature file manipulationSYNOPSISAs a shell command:% cpansign # verify an existing SIGNATURE, or # make a new one if none exists % cpansign sign # make signature; overwrites existing one % cpansign -s # same thing % cpansign verify # verify a signature % cpansign -v # same thing % cpansign -v --skip # ignore files in MANIFEST.SKIP % cpansign help # display this documentation % cpansign -h # same thing In programs: use Module::Signature qw(sign verify SIGNATURE_OK); sign(); sign(overwrite => 1); # overwrites without asking # see the CONSTANTS section below (verify() == SIGNATURE_OK) or die "failed!"; DESCRIPTIONModule::Signature adds cryptographic authentications to CPAN distributions, via the special SIGNATURE file.If you are a module user, all you have to do is to remember to run "cpansign -v" (or just "cpansign") before issuing "perl Makefile.PL" or "perl Build.PL"; that will ensure the distribution has not been tampered with. Module authors can easily add the SIGNATURE file to the distribution tarball; see "NOTES" below for how to do it as part of "make dist". If you really want to sign a distribution manually, simply add "SIGNATURE" to MANIFEST, then type "cpansign -s" immediately before "make dist". Be sure to delete the SIGNATURE file afterwards. Please also see "NOTES" about MANIFEST.SKIP issues, especially if you are using Module::Build or writing your own MANIFEST.SKIP. Signatures made with Module::Signature prior to version 0.82 used the SHA1 algorithm by default. SHA1 is now considered broken, and therefore module authors are strongly encouraged to regenerate their SIGNATURE files. Users verifying old SHA1 signature files will receive a warning. VARIABLESNo package variables are exported by default.
ENVIRONMENTModule::Signature honors these environment variables:
CONSTANTSThese constants are not exported by default.
NOTESSigning your module as part of "make dist"The easiest way is to use Module::Install:sign; # put this before "WriteAll" WriteAll; For ExtUtils::MakeMaker (version 6.18 or above), you may do this: WriteMakefile( (MM->can('signature_target') ? (SIGN => 1) : ()), # ... original arguments ... ); Users of Module::Build may do this: Module::Build->new( (sign => 1), # ... original arguments ... )->create_build_script; MANIFEST.SKIP Considerations(The following section is lifted from Iain Truskett's Test::Signature module, under the Perl license. Thanks, Iain!)It is imperative that your MANIFEST and MANIFEST.SKIP files be accurate and complete. If you are using "ExtUtils::MakeMaker" and you do not have a MANIFEST.SKIP file, then don't worry about the rest of this. If you do have a MANIFEST.SKIP file, or you use "Module::Build", you must read this. Since the test is run at "make test" time, the distribution has been made. Thus your MANIFEST.SKIP file should have the entries listed below. If you're using "ExtUtils::MakeMaker", you should have, at least: #defaults ^Makefile$ ^blib/ ^pm_to_blib ^blibdirs These entries are part of the default set provided by "ExtUtils::Manifest", which is ignored if you provide your own MANIFEST.SKIP file. If you are using "Module::Build", you should have two extra entries: ^Build$ ^_build/ If you don't have the correct entries, "Module::Signature" will complain that you have: ==> MISMATCHED content between MANIFEST and distribution files! <== You should note this during normal development testing anyway. Testing signaturesYou may add this code as t/0-signature.t in your distribution tree:#!/usr/bin/perl use strict; print "1..1\n"; if (!$ENV{TEST_SIGNATURE}) { print "ok 1 # skip Set the environment variable", " TEST_SIGNATURE to enable this test\n"; } elsif (!-s 'SIGNATURE') { print "ok 1 # skip No signature file found\n"; } elsif (!eval { require Module::Signature; 1 }) { print "ok 1 # skip ", "Next time around, consider install Module::Signature, ", "so you can verify the integrity of this distribution.\n"; } elsif (!eval { require Socket; Socket::inet_aton('pool.sks-keyservers.net') }) { print "ok 1 # skip ", "Cannot connect to the keyserver\n"; } else { (Module::Signature::verify() == Module::Signature::SIGNATURE_OK()) or print "not "; print "ok 1 # Valid signature\n"; } __END__ If you are already using Test::More for testing, a more straightforward version of t/0-signature.t can be found in the Module::Signature distribution. Note that "MANIFEST.SKIP" is considered by default only when $ENV{TEST_SIGNATURE} is set to a true value. Also, if you prefer a more full-fledged testing package, and are willing to inflict the dependency of Module::Build on your users, Iain Truskett's Test::Signature might be a better choice. SEE ALSODigest, Digest::SHA, Digest::SHA::PurePerlExtUtils::Manifest, Crypt::OpenPGP, Test::Signature Module::Install, ExtUtils::MakeMaker, Module::Build Dist::Zilla::Plugin::Signature AUTHORSAudrey Tang <cpan@audreyt.org>LICENSEThis work is under a CC0 1.0 Universal License, although a portion of the documentation (as detailed above) is under the Perl license.To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Module-Signature. This work is published from Taiwan. <http://creativecommons.org/publicdomain/zero/1.0>
Visit the GSP FreeBSD Man Page Interface. |