Name

smime_sign — Converts a MIME message to a signed S/MIME message

Synopsis

varchar smime_sign ( in msg_text varchar ,
  in signer_cert varchar ,
  in private_key varchar ,
  in private_key_pass varchar ,
  in signer_CA_certs any ,
  in flags integer );
 

Description

Converts a MIME message to a signed S/MIME message.

Parameters

msg_text

The text of the message

signer_cert

Signer certificate.

private_key

Private Key

private_key_pass

Private Key Pass

signer_CA_certs

Array of strings of CA Certificates

flags

Table 24.79. Bits defined in flags

Mask Name Description
0x1 PKCS7_TEXT add a text/plain content type MIME header
0x2 PKCS7_NOCERTS do not put the signer_CA_certs into the generated PKCS7 signature
0x40 PKCS7_DETACHED do multipart/signed message
0x80 PKCS7_BINARY do not canonize the line endings to CR/LF
0x100 PKCS7_NOATTR Do not include attributes (signing time, supported symmetric algorithms, etc.)
0x200 PKCS7_NOSMIMECAP no SMIME capabilities attributes

Return Types

This function takes a message and converts it to an S/MIME signed message based on the flags value (if supplied - default PKCS7_DETACHED).

Examples

Example 24.373. Signing a MIME Message

Example (where signed.eml contains the output from smime_sign.

select smime_sign ('just a test', file_to_string ('thwate_pub.pem'),
  file_to_string ('thwate_pri.pem'), 'very_secret_password',
	vector (file_to_string ('thwate_ca.pem')), 4*16 + 1);

_______________________________________________________________________________

MIME-Version: 1.0
Content-Type: multipart/signed ; protocol="application/x-pkcs7-signature" ;
  micalg=sha1 ; boundary="----23F1D9057532E126962121287FDB4793"

This is an S/MIME signed message

------23F1D9057532E126962121287FDB4793
Content-Type: text/plain

just a test
------23F1D9057532E126962121287FDB4793
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"

MIILaAYJKoZIhvcNAQcCoIILWTCCC1UCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3
DQEHAaCCCTswggLZMIICQqADAgECAgMD2DgwDQYJKoZIhvcNAQEEBQAwgZIxCzAJ
BgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBg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GlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEkMCIGA1UEAxMb
VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIENBMSswKQYJKoZIhvcNAQkBFhxwZXJz
b25hbC1mcmVlbWFpbEB0aGF3dGUuY29tMB4XDTAwMDgzMDAwMDAwMFoXDTAyMDgy
OTIzNTk1OVowgZIxCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUx
EjAQBgNVBAcTCUNhcGUgVG93bjEPMA0GA1UEChMGVGhhd3Rl
_______________________________________________________________________________