The command sign_smime() signs an email.
This command signs the outgoing email with the authenticated (authenticated()) personal private S/MIME key of the sender (see Users S/MIME) of the email.
Structure of the command
sign_smime(['hash[;pAdd-Ing][;opaque]']);
Return value
positive |
if the message was signed successfully |
negative |
if the signing fails |
Parameters
hash (optional)
This parameter specifies the hash algorithm used for signing (see also Mail Processing Ruleset generator Signing Outgoing e-mails Use default digest for S/MIME signing).
Possible values:
•sha1
•sha256
•sha512
The default setting is sha256
pAdd-Ing (optional)
This parameter enforces the use of the selected padding procedure (see Mail Processing Ruleset generator Signing Outgoing e-mails Prefer RSA-PSS for S/MIME signatures).
Possible values:
•pkcs
•pss
The default setting is pkcs
opaque (optional)
This parameter is used to specify the signature procedure: detached (or clear text) or opaque (see also Settings S/MIME options Use opaque signature).
Possible values:
•true, yes or 1
•false, no or 0
The default setting is 0
Example 1
Line |
Code |
|---|---|
01 |
if (has_smime_key()) { |
02 |
log(1,'S/MIME key available, trying to sign'); |
03 |
if (sign_smime(';;1')) { |
04 |
log(1,'signing successful'); |
05 |
} else { |
06 |
log(1,'signing failed'); |
07 |
} |
08 |
} else { |
09 |
log(1,'no S/MIME key available, do not sign'); |
10 |
} |
Explanation
In this example, it is first checked whether a private S/MIME key is available (line 01). The result is logged (lines 02 and 09). If a private S/MIME key is present, the email is signed using the SHA256 algorithm (default) in the opaque procedure (line 03) and the result of this action is also logged (lines 04 or 06).