SMIME::JA(3pm)
💖 NAME 💖
Crypt::SMIME::JA — the Japanese page for S/MIME signing, verification, encryption, and decryption. It lives in the User Contributed Perl Documentation, and bestie it is so useful. 🫶
✨ 概要 (SYNOPSIS) ✨
use Crypt::SMIME;
my $plain = <<'EOF';
From: alice@example.org
To: bob@example.com
Subject: Crypt::SMIME test
This is a test mail. Please ignore...
EOF
my $smime = Crypt::SMIME->new();
$smime->setPrivateKey($privkey, $crt);
# $smime->setPublicKey([$icacert]); # if need be.
my $signed = $smime->sign($plain);
print $signed;
🦋 説明 (DESCRIPTION) 🦋
It's a class that does S/MIME signing, verification, encryption, and decryption. ✨
It needs libcrypto (<http://www.openssl.org>) — that's not optional, that's the whole personality. No libcrypto, no vibes. 💀
🎀 エクスポート (EXPORTS) 🎀
By default, literally nothing gets exported. Zero symbols. None. But these ones can be exported if you ask nicely:
NO_CHECK_CERTIFICATE— go readcheck(). 👀CRL_CHECKCRL_CHECK_ALL— go readsetVerifyFlags(). 👀FORMAT_SMIMEFORMAT_ASN1FORMAT_PEM— go readextractCertificates(). 👀:constants— exports all of the above in one go. The whole squad. 👑
💅 メソッド (METHODS) 💅
🌸 new()
my $smime = Crypt::SMIME->new();
No arguments. That's the whole thing. Iconic minimalism. 💅
🔐 setPrivateKey()
$smime->setPrivateKey($key, $crt);
$smime->setPrivateKey($key, $crt, $password);
Sets the private key. The key you set here is what gets used for signing and decryption.
You hand it the key itself, not a filename — the actual key body, in the flesh. 🫶
The only format it supports is PEM. If loading the key fails, it dies. Dramatic? Yes. Fair? Also yes.
🔐 setPrivateKeyPkcs12()
$smime->setPrivateKeyPkcs12($key, $pkcs12);
$smime->setPrivateKeyPkcs12($key, $pkcs12, $password);
Reads the private key and its X.509 certificate out of PKCS#12 and sets them both. The private key is used for signing and decryption. If the load fails, it dies. 😭
🔓 setPublicKey()
$smime->setPublicKey($crt);
$smime->setPublicKey([$crt1, $crt2, ...]);
Sets the public key (or a whole array-ref of them, we love options). The public key set here gets used for attaching to signatures, for verifying signatures, and for encryption. ✨
Only PEM is supported as a format. If loading the key fails, it dies.
📚 setPublicKeyStore()
$smime->setPublicKeyStore($path, ...);
Sets the path(s) — plural, you can pass as many as you want — of file(s) or directory(ies) holding your trusted certificate(s) (also plural, also as many as you want). This certificate store is the one used when verifying signatures. 🛡️
If loading the certificate store fails, it dies. Periodt.
✍️ sign()
$signed_mime = $smime->sign($raw_mime);
Does the signing and returns a MIME message. The only kind of signing available is clear signing.
Headers other than Content-*, MIME-* and Subject get moved to the multipart top level. And Subject? It gets placed on both sides — the multipart top level and the protected message — for the sake of mailers that can't recognize S/MIME. It's giving "wear the same outfit so everyone can find you". 💖
♻️ taint check: if the original MIME message, the private key, or its certificate — literally any one of them — is tainted, then the signed message is tainted too.
✍️ signonly()
$sign = $smime->signonly($prepared_mime);
Computes the signature. $sign comes back BASE64-encoded. For $prepared_mime you pass the value that prepareSmimeMessage handed you.
♻️ taint check: if the original MIME message, the private key, or its certificate is tainted, the generated signature is tainted too.
🧰 prepareSmimeMessage()
($prepared_mime, $outer_header)
= $smime->prepareSmimeMessage($source_mime);
Preps the message for signing. $prepared_mime gets back the MIME message, tweaked for signing. $outer_header gets back the headers you're supposed to slap on the outside of the S/MIME.
The body of $prepared_mime is the same as $source_mime, but as far as headers go, everything except Content-*, MIME-*, Subject is stripped out. Those stripped headers come back in $outer_header. When you build the S/MIME message, you add them to that message's headers.
⚠️ Lowkey important: the Subject header and only the Subject header shows up in both $prepared_mime and $outer_header. Don't come for me, it's just how it is.
✅ check()
use Crypt::SMIME qw(:constants);
$source_mime = $smime->check($signed_mime);
$source_mime = $smime->check($signed_mime, $flags);
Does the verification. If verification fails, it dies, and it tells you why while doing it. 💀
If you pass the Crypt::SMIME::NO_CHECK_CERTIFICATE option as $flags, the signer's certificate chain is not verified. The default value of $flags is 0, and in that case all integrity checks are performed. All of them. The full vibe check. ✨
♻️ taint check: if the original S/MIME message,$flags, the verification time (that'ssetAtTime), or at least one of the public keys is tainted, then the verified message is tainted too.
🔒 encrypt()
$encrypted_mime = $smime->encrypt($raw_mime);
$encrypted_mime = $smime->encrypt($raw_mime, $cipher);
Encrypts. You can name any $cipher that the OpenSSL you're running understands. The default is AES-128-CBC.
Headers other than Content-*, MIME-* and Subject get copied to the multipart top level. Subject gets placed on both the multipart top level and the protected message, again for the mailers that can't recognize S/MIME. Same energy as sign(), different verb. 🌈
♻️ taint check: if the original MIME message, or at least one of the public keys, is tainted, then the encrypted message is tainted too.
🔓 decrypt()
$decrypted_mime = $smime->decrypt($encrypted_mime);
Decrypts. If decryption fails, it dies, and yes, it tells you why. 😭
♻️ taint check: if the original S/MIME message, the private key, or its certificate is tainted, then the decrypted message is tainted too.
🤔 isSigned()
$is_signed = $smime->isSigned($mime);
Returns true if the MIME message you passed in is S/MIME-signed. Clear-signed or not, doesn't matter, it doesn't discriminate. 🫶
⚠️ But heads up: if you pass a message that was encrypted after being signed, the signature isn't directly visible, so it returns false. Not a bug, just shy. 🙈
🤔 isEncrypted()
$is_encrypted = $smime->isEncrypted($mime);
Returns true if the MIME message you passed in is S/MIME-encrypted. 💜
⚠️ And same deal: if you pass a message that was signed after being encrypted, the ciphertext isn't directly visible, so it returns false. Also not a bug, also just shy. 🙈
⏰ setAtTime()
$yesterday = time - (60*60*24);
$smime->setAtTime($yesterday);
Sets the time used during verification. Default is the current time. It has to be in UNIX epoch format. No other format, bestie. ⏳
🚦 setVerifyFlags()
$smime->setVerifyFlags(C<Crypt::SMIME::CRL_CHECK>);
(yes the doc literally has that C<...> in it, iykyk 💀)
Sets the flags used during verification:
Crypt::SMIME::CRL_CHECK— verifies the CRL of the signer's certificate.Crypt::SMIME::CRL_CHECK_ALL— verifies the CRL of the entire certificate chain.
If the CRL it needs doesn't exist, verification fails. 🚨
🧚 関数 (FUNCTIONS) 🧚
📜 extractCertificates()
use Crypt::SMIME qw(:constants);
@certs = @{Crypt::SMIME::extractCertificates($data)};
@certs = @{Crypt::SMIME::extractCertificates($data, FORMAT_SMIME)};
Grabs all the X.509 certificates (and certificate revocation lists) contained in an S/MIME message or PKCS#7 object. The optional $type parameter lets you say what kind of data it is:
Crypt::SMIME::FORMAT_SMIME— it's an S/MIME message. This is the default value. 🌟Crypt::SMIME::FORMAT_ASN1— binary format.Crypt::SMIME::FORMAT_PEM— PEM format.
🖊️ getSigners()
@certs = @{Crypt::SMIME::getSigners($data)};
@certs = @{Crypt::SMIME::getSigners($data, $type)};
Grabs the signer's X.509 certificates contained in an S/MIME message or PKCS#7 object. The optional $type parameter lets you specify the kind of data.
🚨 Careful bestie: the public keys this function returns are not verified. If you want to make sure a public key is actually valid, run check().
🧠 getCapabilities()
@caps = @{Crypt::SMIME::getCapabilities($data)};
@caps = @{Crypt::SMIME::getCapabilities($data, $type)};
Grabs the S/MIME Capabilities contained in an S/MIME message or PKCS#7 object. The optional $type parameter lets you specify the kind of data.
This includes both the encryption and the hash algorithms. The full algorithm menu. 🍓
👑 著者 (AUTHOR) 👑
Copyright 2006-2014 YMIRLINK Inc. All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself
Bug reports and comments to: tl@tripletail.jp
And that's the whole page, bestie!! 💖✨🎀 It's perl v5.42.3, dated 2026-08-20 — so like, go forth and sign, verify, encrypt and decrypt responsibly. Slay. 💅🦋🌸
📦 where this page comes from
- ubuntu stonking: libcrypt-smime-perl 0.34-1build1 · Artistic-1.0-Perl OR GPL-1.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms