SMIME Class
Properties Methods Events Config Settings Errors
The S/MIME class implements the S/MIME standard for encryption and decryption with public key cryptography and X.509 digital certificates.
Syntax
ipworkssmime.SMIME
Remarks
The S/MIME class implements the S/MIME V3 standard for encryption and decryption using Public Key Cryptography Standards (PKCS). In addition, the class can be used to both generate and verify RSA digital signatures. Using this class for decrypting or signing requires a valid digital certificate with a private key.
Before performing an operation the input and output values should be specified.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
Signing
To sign the current data included in the input message with a certificate, the Certificate property must be set to a valid Certificate object for the signing certificate. The IncludeCertificate and DetachedSignature properties allow you to specify additional details about the signing process. By setting IncludeCertificate to True, digital certificates can be encoded and included in message signature when signing the document. Including a certificate is the preferred method of building signed messages. In addition the S/MIME class can also generate PKCS #7 formatted detached digital signatures and envelopes by specifying DetachedSignature.
Encrypting
To encrypt a message with the class in a PKCS envelope, you must first specify the Certificate for each recipient in the RecipientCerts collection to encrypt the message with. You can easily add these with the AddRecipientCert method. Once you have done this you can call the Encrypt method to encrypt the message with the recipient certificates.
In addition, the class allows you to sign and encrypt simultaneously with the SignAndEncrypt method. You must set all of the properties needed for both Sign and Encrypt
The result of the encrypted or signed data will be replaced in the OutputMessage property and the OutputMessageHeaders property will be filled with the appropriate mime headers if applicable.
Decrypting
Decrypting PKCS envelopes is handled with the Decrypt method. When this method is called, the class will attempt to find an appropriate certificate in the Certificate property that matches the encrypting certificate. If it cannot find an appropriate certificate, an exception will be thrown and the message will not be decrypted.
Verifying Signatures
In addition, the S/MIME class can be used to verify signatures included in signed messages or documents. After specifying the input, VerifySignature can then be used to verify the signature. If the message does not have a certificate attached, more then likely an exception will be thrown and the class will not be able to verify the signature. If VerifySignature is successful, the SignerCert and SignerCertChain properties will be filled with the certificate information of the message signer. This information can be used to verify the signing certificates.
Similar to SignAndEncrypt, DecryptAndVerifySignature can be used to both decrypt and verify the message in Message.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
Certificate | This property includes the current selected certificate. |
DetachedSignature | This property specifies whether to include a detached signature when signing a message. |
EncryptingAlgorithm | The property includes textual description of the encrypting algorithm. |
IncludeCertificate | This property specifies whether to include the signer's certificate with the signed message. |
IncludeChain | This property specifies whether to include the signer's certificate chain with the signed message. |
IncludeHeaders | This property tells the class whether to include the headers when encoding the message. |
InputFile | This property includes the file to process. |
InputMessage | This property includes the message to process. |
InputMessageHeaders | This property includes a collection of headers from the S/MIME message. |
InputMessageHeadersString | This property includes the string version of headers from the S/MIME message. |
InternalHeaders | This property includes the headers of the MIME entity inside the encrypted or signed message. |
OutputFile | This property specifies the output file. |
OutputMessage | This property includes the output message after processing. |
OutputMessageHeaders | This property includes a collection of headers from the S/MIME message. |
OutputMessageHeadersString | This property includes a string version of headers from the S/MIME message. |
Overwrite | This property indicates whether or not the class should overwrite files. |
RecipientCerts | This property includes a collection of recipient certificates of the message. |
SignerCert | This property contains the certificate of the message signer. |
SignerCertChain | This property includes the certificate chain of the signing certificate. |
SigningAlgorithm | This property includes a textual description of the signature hash algorithm. |
UseOAEP | This property specifies whether or not to use Optimal Asymmetric Encryption Padding (OAEP). |
UsePSS | This property specifies whether or not RSA-PSS will be used during signing and verification. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
AddRecipientCert | This method is used to add recipient certificates used to encrypt messages. |
CheckMessageEncrypted | This method checks whether or not the current message is encrypted. |
CheckMessageSigned | This method checks whether or not the current message is signed. |
Config | Sets or retrieves a configuration setting. |
Decrypt | This method decrypts the current Message . |
DecryptAndVerifySignature | This method decrypts and verifies the signature of the current message. |
Encrypt | This method encrypts the message. |
GetRecipientInfo | This method gets the recipient information for an encrypted message. |
GetSignerCertInfo | This method gets the signature information for an signed message. |
Reset | This method resets the class properties. |
SetInputStream | This method sets the stream from which the class will read data to encode or decode. |
SetOutputStream | This method includes the stream to which the class will write the fully encoded or decoded S/MIME data. |
Sign | This method signs the current message. |
SignAndEncrypt | This method signs and encrypts the current message. |
VerifySignature | This method verifies the signature of the current message. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
Error | Fired when information is available about errors during data delivery. |
RecipientInfo | This event is fired for each recipient certificate of the encrypted message. |
SignerCertInfo | This event is fired during verification of the signed message. |
Config Settings
The following is a list of config settings for the class with short descriptions. Click on the links for further details.
ApplyB64Encoding | Instructs the class to base64 encode the message when signing or encrypting. |
CloseInputStreamAfterProcess | Determines whether or not the input stream is closed after processing. |
CloseOutputStreamAfterProcess | Determines whether or not the output stream is closed after processing. |
CSP | The Cryptographic Service Provider. |
GenerateSignatureTimestamp | Whether to generate timestamps in signatures. |
IncludeHeaders | Tells the class whether to include the headers when encoding the message. |
IncludeInternalHeaders | Tells the class whether or not to include the internal headers when encoding the message. |
InputContentTransferEncoding | Sets the Content-Transfer-Encoding for the signed message. |
InputContentType | Sets the Content-Type for the signed message. |
InputMessageEncrypted | Whether or not the input message is encrypted. |
InputMessageSigned | Whether or not the input message is signed. |
NormalizeCRLF | Whether or not the class will normalize line endings of the input data to CrLf. |
OAEPMGF1HashAlgorithm | The MGF1 hash algorithm used with OAEP. |
OAEPParams | The hex encoded OAEP parameters. |
OAEPRSAHashAlgorithm | The RSA hash algorithm used with OAEP. |
ParseInternalHeaders | Tells the class whether or not to parse the message part headers when decrypting a message. |
RecipientCert | Used to specify the public certificate when using a PEM key to decrypt. |
RecipientCertFile | Used to specify the public certificate file when using a PEM key to decrypt. |
RecipientInfoType | The type of signer information to include in the signed message. |
SignerInfoType | The type of signer information to include in the signed message. |
UseAlgorithmOIDs | Whether OIDs are used when providing information about the algorithms. |
UseCryptoAPI | Whether to use the Microsoft Crypto API for cryptographic message generation. |
VerifyCertChain | Whether to verify the certificate chain of the certificate used to sign the message. |
BuildInfo | Information about the product's build. |
GUIAvailable | Whether or not a message loop is available for processing events. |
LicenseInfo | Information about the current license. |
MaskSensitiveData | Whether sensitive data is masked in log messages. |
UseDaemonThreads | Whether threads created by the class are daemon threads. |
UseInternalSecurityAPI | Whether or not to use the system security libraries or an internal implementation. |
Certificate Property (SMIME Class)
This property includes the current selected certificate.
Syntax
public Certificate getCertificate(); public void setCertificate(Certificate certificate);
Remarks
This property is populated when a specified certificate is found or loaded by the class. This property is used to specify private keys. Set this property to a valid Certificate object to perform different operations, such as Sign, Decrypt, SignAndEncrypt, or DecryptAndVerifySignature.
Please refer to the Certificate type for a complete list of fields.DetachedSignature Property (SMIME Class)
This property specifies whether to include a detached signature when signing a message.
Syntax
public boolean isDetachedSignature(); public void setDetachedSignature(boolean detachedSignature);
Default Value
True
Remarks
This property specifies whether to include a detached signature when signing a message. If the value of this property is True, Message will be encoded as a multipart/signed MIME message with a detached signature when calling Sign. This will create a message with two MIME parts, one with the contents of Message, and another with the detached signature.
If this property is False, the current contents of Message will be PKCS encoded and included with the signature in Message. This will create a single-part message with no MIME boundaries.
EncryptingAlgorithm Property (SMIME Class)
The property includes textual description of the encrypting algorithm.
Syntax
public String getEncryptingAlgorithm(); public void setEncryptingAlgorithm(String encryptingAlgorithm);
Default Value
"3DES"
Remarks
This property contains either the name of the algorithm (such as 3DES or AES), or an object identifier (OID) string representing the algorithm.
Possible values are as follows:
- "3DES"
- "DES"
- "RC2CBC40"
- "RC2CBC64"
- "RC2CBC128" or "RC2"
- "AESCBC128" or "AES"
- "AESCBC192"
- "AESCBC256"
- "AESGCM128" or "AESGCM"
- "AESGCM192"
- "AESGCM256"
IncludeCertificate Property (SMIME Class)
This property specifies whether to include the signer's certificate with the signed message.
Syntax
public boolean isIncludeCertificate(); public void setIncludeCertificate(boolean includeCertificate);
Default Value
True
Remarks
If this property is set to True, the certificate used to sign the message will be encoded and included in a message signature when calling Sign or SignAndEncrypt.
Including a certificate is the preferred method of building signed messages. If you do not include a certificate, the message recipient may not be able to verify the sender's signature.
IncludeChain Property (SMIME Class)
This property specifies whether to include the signer's certificate chain with the signed message.
Syntax
public boolean isIncludeChain(); public void setIncludeChain(boolean includeChain);
Default Value
False
Remarks
If this property is set to True, the entire certificate's chain that was used to sign the message will be encoded and included in the message signature when calling Sign or SignAndEncrypt.
Note: To include the chain, the IncludeCertificate property must also be set to true.
IncludeHeaders Property (SMIME Class)
This property tells the class whether to include the headers when encoding the message.
Syntax
public boolean isIncludeHeaders(); public void setIncludeHeaders(boolean includeHeaders);
Default Value
False
Remarks
If True, the class will include the headers when Sign, Encrypt, or SignAndEncrypt are called. If False, only the message will be encoded.
The default value for IncludeHeaders is False.
InputFile Property (SMIME Class)
This property includes the file to process.
Syntax
public String getInputFile(); public void setInputFile(String inputFile);
Default Value
""
Remarks
This property specifies the file to be processed. Set this property to the full or relative path to the file that will be processed.
Encrypt and/or Sign
When encrypting or signing, this may be set to a file containing content that will be encrypted and/or signed.
Decrypt and/or Verify
When decrypting or verifying a signature, this may be set to a file containing the fully encoded S/MIME message.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
- SetInputStream
- InputFile
- InputMessage
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
InputMessage Property (SMIME Class)
This property includes the message to process.
Syntax
public byte[] getInputMessage(); public void setInputMessage(byte[] inputMessage);
Default Value
""
Remarks
This property specifies the message to be processed.
Encrypt and/or Sign
When encrypting or signing, this may be set to the content that will be encrypted and/or signed.
Decrypt and/or Verify
When decrypting or verifying a signature, this may be set to the fully encoded S/MIME message.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
- SetInputStream
- InputFile
- InputMessage
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
InputMessageHeaders Property (SMIME Class)
This property includes a collection of headers from the S/MIME message.
Syntax
public HeaderList getInputMessageHeaders(); public void setInputMessageHeaders(HeaderList inputMessageHeaders);
Remarks
This property contains a collection of headers from the S/MIME message.
This property may be set to the headers of the message that will be decrypted/verified.
This property is not available at design time.
Please refer to the Header type for a complete list of fields.InputMessageHeadersString Property (SMIME Class)
This property includes the string version of headers from the S/MIME message.
Syntax
public String getInputMessageHeadersString(); public void setInputMessageHeadersString(String inputMessageHeadersString);
Default Value
""
Remarks
This property contains the string version of headers from the S/MIME message.
This property may be set to the headers of the message that will be decrypted/verified.
InternalHeaders Property (SMIME Class)
This property includes the headers of the MIME entity inside the encrypted or signed message.
Syntax
public String getInternalHeaders(); public void setInternalHeaders(String internalHeaders);
Default Value
""
Remarks
After an encryption, decryption, signing, or verification operation is completed, this property shows the headers of the encrypted or signed message part.
This property is not available at design time.
OutputFile Property (SMIME Class)
This property specifies the output file.
Syntax
public String getOutputFile(); public void setOutputFile(String outputFile);
Default Value
""
Remarks
This property specifies the file to which the output will be written. This may be set to an absolute or relative path.
Encrypt and/or Sign
When encrypting or signing, this specifies a file where the fully encoded S/MIME message will be written.
Decrypt and/or Verify
When decrypting or verifying a signature, this specifies a file where the decrypted/verified content will be written.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
OutputMessage Property (SMIME Class)
This property includes the output message after processing.
Syntax
public byte[] getOutputMessage();
Default Value
""
Remarks
This property will be populated with the output of the operation if OutputFile and SetOutputStream are not set.
Encrypt and/or Sign
When encrypting or signing, this will hold the fully encoded S/MIME message.
Decrypt and/or Verify
When decrypting or verifying a signature, this will hold the decrypted/verified content.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
This property is read-only.
OutputMessageHeaders Property (SMIME Class)
This property includes a collection of headers from the S/MIME message.
Syntax
public HeaderList getOutputMessageHeaders();
Remarks
The class will populate this property after signing and/or encrypting.
The user should use these additional headers when emailing or sending the OutputMessage. This can be done by including these headers in the OtherHeaders property of the class that you wish to send the message with.
After the decryption or verification, this property contains the headers of the verified or decrypted message.
This property is read-only and not available at design time.
Please refer to the Header type for a complete list of fields.OutputMessageHeadersString Property (SMIME Class)
This property includes a string version of headers from the S/MIME message.
Syntax
public String getOutputMessageHeadersString();
Default Value
""
Remarks
This property contains the string version of headers from the S/MIME message. The class will populate this property after signing and/or encrypting.
The user should use these additional headers when emailing or sending the OutputMessage. This can be done by including these headers in the OtherHeaders property of the class that you wish to send the message with.
After the decryption or verification, this property contains the headers of the verified or decrypted message.
This property is read-only.
Overwrite Property (SMIME Class)
This property indicates whether or not the class should overwrite files.
Syntax
public boolean isOverwrite(); public void setOverwrite(boolean overwrite);
Default Value
True
Remarks
This property indicates whether or not the class will overwrite OutputFile. If Overwrite is False, an error will be thrown whenever OutputFile exists before an operation. The default value is False.
RecipientCerts Property (SMIME Class)
This property includes a collection of recipient certificates of the message.
Syntax
public CertificateList getRecipientCerts(); public void setRecipientCerts(CertificateList recipientCerts);
Remarks
This property is used to specify the certificates of the intended recipients of the encrypted message. This property must be set before calling Encrypt or SignAndEncrypt methods.
This property's collection must be filled out with valid public key Certificate type objects. To set a certificate, you may set the Encoded field to the encoded certificate. To select a certificate, use the Store and Subject fields.
This collection is indexed from 0 to size -1.
This property is not available at design time.
Please refer to the Certificate type for a complete list of fields.SignerCert Property (SMIME Class)
This property contains the certificate of the message signer.
Syntax
public Certificate getSignerCert(); public void setSignerCert(Certificate signerCert);
Remarks
This property contains the certificate of the message signer. When calling VerifySignature or DecryptAndVerifySignature, this property will contain the certificate of the sender, if attached.
To verify messages without an attached certificate, set this property before calling VerifySignature or DecryptAndVerifySignature.
Please refer to the Certificate type for a complete list of fields.SignerCertChain Property (SMIME Class)
This property includes the certificate chain of the signing certificate.
Syntax
public CertificateList getSignerCertChain();
Remarks
This property contains the certificate chain of the signing certificate. When calling VerifySignature or DecryptAndVerifySignature, this property will be populated with the certificate chain of the sender if attached.
Note: The SignerCert property will contain the signing certificate. The certificates in the signing certificate's chain will be placed in this property's collection.
This property is read-only and not available at design time.
Please refer to the Certificate type for a complete list of fields.SigningAlgorithm Property (SMIME Class)
This property includes a textual description of the signature hash algorithm.
Syntax
public String getSigningAlgorithm(); public void setSigningAlgorithm(String signingAlgorithm);
Default Value
"SHA256"
Remarks
This property specifies the hash algorithm used to prepare the message digest for signature.
This property must contain either the name of the algorithm (such as MD5 or SHA1), or an object Id (OID) string representing the hash algorithm. Possible values are as follows:
- sha1
- md5
- sha-256 (default)
- sha-384
- sha-512
- sha-224
When read, the value of the property always contains the OID of the algorithm, or an empty string if the algorithm is unknown.
UseOAEP Property (SMIME Class)
This property specifies whether or not to use Optimal Asymmetric Encryption Padding (OAEP).
Syntax
public boolean isUseOAEP(); public void setUseOAEP(boolean useOAEP);
Default Value
False
Remarks
This property specifies whether or not to use Optimal Asymmetric Encryption Padding (OAEP). By default, this value is False and the class will use PKCS1.
To specify nondefault OAEP options, please see OAEPRSAHashAlgorithm, OAEPMGF1HashAlgorithm, and OAEPParams
UsePSS Property (SMIME Class)
This property specifies whether or not RSA-PSS will be used during signing and verification.
Syntax
public boolean isUsePSS(); public void setUsePSS(boolean usePSS);
Default Value
False
Remarks
This property specifies whether or not RSA-PSS will be used when signing and verifying messages. The default value is False.
AddRecipientCert Method (SMIME Class)
This method is used to add recipient certificates used to encrypt messages.
Syntax
public void addRecipientCert(byte[] certEncoded);
Remarks
This method is used to add recipient certificates to the internal MessageRecipients collection used to encrypt the Message. The recipient certificate must be a valid PKCS-encoded certificate. If the certificate provided is Base64 encoded, it will be decoded first by the object.
The CertMgr class may be used to retrieve the appropriate certificate from the system.
CheckMessageEncrypted Method (SMIME Class)
This method checks whether or not the current message is encrypted.
Syntax
public boolean checkMessageEncrypted();
Remarks
This method is used to check whether or not the current message is encrypted. This method will return True, if the current message appears to be encrypted, according to the value of OutputMessageHeaders.
CheckMessageSigned Method (SMIME Class)
This method checks whether or not the current message is signed.
Syntax
public boolean checkMessageSigned();
Remarks
This method is used to check whether or not the current message is signed. This method will return True, if the current message appears to be signed, according to the value of OutputMessageHeaders.
Note: A message that is both signed and encrypted will not appear to be signed until after it is decrypted.
Config Method (SMIME Class)
Sets or retrieves a configuration setting.
Syntax
public String config(String configurationString);
Remarks
Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.
Decrypt Method (SMIME Class)
This method decrypts the current Message .
Syntax
public void decrypt();
Remarks
This method takes attempts to decrypt the encrypted message using the certificate in Certificate.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
DecryptAndVerifySignature Method (SMIME Class)
This method decrypts and verifies the signature of the current message.
Syntax
public void decryptAndVerifySignature();
Remarks
This method attempts to both decrypt and verify the signature of the message. All of the properties affected by calling the Decrypt and VerifySignature methods are affected in the same manner.
Note: This function does not attempt to check the validity of the signing certificate.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
Encrypt Method (SMIME Class)
This method encrypts the message.
Syntax
public void encrypt();
Remarks
This method encrypts the data specified in SetInputStream, InputFile or InputMessage in a PKCS-encoded envelope with all of the recipient certificates specified in the MessageRecipients collection.
The result of the encrypted data will be written to the stream specified by SetOutputStream, OutputFile, or OutputMessage. The OutputMessageHeaders property will be filled with the required S/MIME headers.
Note: The message headers, including the Sender, Recipient(s), and Subject, are not encrypted. If this is sensitive information, consider including these headers in the message body as a MIME entity and providing other headers for the S/MIME wrapper.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
GetRecipientInfo Method (SMIME Class)
This method gets the recipient information for an encrypted message.
Syntax
public void getRecipientInfo();
Remarks
This method will fire a RecipientInfo event for every recipient certificate for which the Message has been encrypted. The event will contain information about the Issuer and the SerialNumber for each recipient of the message.
GetSignerCertInfo Method (SMIME Class)
This method gets the signature information for an signed message.
Syntax
public void getSignerCertInfo();
Remarks
This method retrieves information about the certificate used to sign the message. This may be called before calling VerifySignature to determine which certificate should be loaded for verification.
When this method is called, the SignerCertInfo event fires once for each signer of the message. Use the parameters of the SignerCertInfo to determine which certificate to specify before calling VerifySignature.
Note: Use of this method is optional. If no certificate is specified before calling VerifySignature, the class will fire the SignerCertInfo and a certificate may be loaded from within the event at that time (if necessary).
Reset Method (SMIME Class)
This method resets the class properties.
Syntax
public void reset();
Remarks
This method resets the values of all message and certificate properties. It is an easy way to reset the class properties before starting to populate with new values.
SetInputStream Method (SMIME Class)
This method sets the stream from which the class will read data to encode or decode.
Syntax
public void setInputStream(java.io.InputStream inputStream);
Remarks
This method sets the stream from which the class will read data to encode or decode.
Encrypt and/or Sign
When encrypting or signing, this may be set to a stream with the content that will be encrypted and/or signed.
Decrypt and/or Verify
When decrypting or verifying a signature, this may be set to a stream with the fully encoded S/MIME message.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
- SetInputStream
- InputFile
- InputMessage
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
SetOutputStream Method (SMIME Class)
This method includes the stream to which the class will write the fully encoded or decoded S/MIME data.
Syntax
public void setOutputStream(java.io.OutputStream outputStream);
Remarks
This method contains the stream to which the class will write the fully encoded or decoded S/MIME data.
Encrypt and/or Sign
When encrypting or signing, this may be set to a stream where the fully encoded S/MIME message will be written.
Decrypt and/or Verify
When decrypting or verifying a signature, this may be set to a stream where the decrypted/verified content will be written.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
Sign Method (SMIME Class)
This method signs the current message.
Syntax
public void sign();
Remarks
This method digitally signs the input data with the the certificate provided. Certificates are provided by specifying the Certificate property. The IncludeCertificate and DetachedSignature properties allow you to specify addition details about what to include when signing the message.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
SignAndEncrypt Method (SMIME Class)
This method signs and encrypts the current message.
Syntax
public void signAndEncrypt();
Remarks
This method both signs and encrypts the input message into a single PKCS-encoded envelope. The value in DetachedSignature is ignored: the class will always generate an attached signature when calling this method. All other properties used by calling the Sign and Encrypt methods are used in the same manner.
Note: The message headers, including the Sender, Recipient(s), and Subject, are not encrypted. If this is sensitive information, consider including these headers in the message body as a MIME entity and providing other headers for the S/MIME wrapper.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
VerifySignature Method (SMIME Class)
This method verifies the signature of the current message.
Syntax
public void verifySignature();
Remarks
This method attempts to verify the signature of the input message. If the message does not have a certificate attached, the class will attempt to verify the signature using the certificate supplied in SignerCert (if any). If no certificate is found, the class throws an exception.
If this method is successful, the SignerCert property will contain the certificate information of the message signer.
Note: This function does not attempt to check the validity of the signing certificate.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found, the search stops. The order in which the output properties are checked is as follows:
- SetOutputStream
- OutputFile
- OutputMessage: The output data is written to this property if no other destination is specified.
When using streams, you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.
The headers of the input message (if any) will be read from InputMessageHeaders or InputMessageHeadersString.
The headers of the resulting message will be available in the OutputMessageHeaders and OutputMessageHeadersString properties.
Error Event (SMIME Class)
Fired when information is available about errors during data delivery.
Syntax
public class DefaultSMIMEEventListener implements SMIMEEventListener { ... public void error(SMIMEErrorEvent e) {} ... } public class SMIMEErrorEvent { public int errorCode; public String description; }
Remarks
The Error event is fired in case of exceptional conditions during message processing. Normally the class throws an exception.
The ErrorCode parameter contains an error code, and the Description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.
RecipientInfo Event (SMIME Class)
This event is fired for each recipient certificate of the encrypted message.
Syntax
public class DefaultSMIMEEventListener implements SMIMEEventListener { ... public void recipientInfo(SMIMERecipientInfoEvent e) {} ... } public class SMIMERecipientInfoEvent { public String issuer; public String serialNumber; public String subjectKeyIdentifier; public String encryptionAlgorithm; }
Remarks
When GetRecipientInfo is called on a valid encrypted message, this event will fire once for each recipient certificate that the message has been encrypted for. This may be used to identify the certificate to load.
Issuer is the subject of the issuer certificate.
SerialNumber is the serial number of the encryption certificate.
SubjectKeyIdentifier is the X.509 subjectKeyIdentifier extension value of the certificate used to sign the message encoded as a hex string.
EncryptionAlgorithm is the encryption algorithm used to encrypt the message. Possible values are as follows:
- "3DES"
- "DES"
- "RC2CBC40"
- "RC2CBC64"
- "RC2CBC128" or "RC2"
- "AESCBC128" or "AES"
- "AESCBC192"
- "AESCBC256"
- "AESGCM128" or "AESGCM"
- "AESGCM192"
- "AESGCM256"
SignerCertInfo Event (SMIME Class)
This event is fired during verification of the signed message.
Syntax
public class DefaultSMIMEEventListener implements SMIMEEventListener { ... public void signerCertInfo(SMIMESignerCertInfoEvent e) {} ... } public class SMIMESignerCertInfoEvent { public String issuer; public String serialNumber; public String subjectKeyIdentifier; public byte[] certEncoded; }
Remarks
During verification, this event will be raised while parsing the signer's certificate information. The parameters that are populated depend on the options used when the message was originally signed. This information may be used to select the correct certificate for SignerCert to verify the signature. The following parameters may be populated:
Issuer specifies the subject of the issuer of the certificate used to sign the message.
SerialNumber is the serial number of the certificate used to sign the message.
SubjectKeyIdentifier is the X.509 subjectKeyIdentifier extension value of the certificate used to sign the message encoded as a hex string.
CertEncoded is the PEM (Base64 encoded) public certificate needed to verify the signature.
Note: When this value is present, the class will automatically use this value to perform signature verification.
The SignerCert property may be set from within this event. In this manner, the decision of which signer certificate to load may be delayed until the parameters of this event are inspected and the correct certificate can be located and loaded.
Certificate Type
This is the digital certificate being used.
Remarks
This type describes the current digital certificate. The certificate may be a public or private key. The fields are used to identify or select certificates.
Fields
EffectiveDate
String (read-only)
Default Value: ""
The date on which this certificate becomes valid. Before this date, it is not valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:
23-Jan-2000 15:00:00.
ExpirationDate
String (read-only)
Default Value: ""
The date on which the certificate expires. After this date, the certificate will no longer be valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:
23-Jan-2001 15:00:00.
ExtendedKeyUsage
String (read-only)
Default Value: ""
A comma-delimited list of extended key usage identifiers. These are the same as ASN.1 object identifiers (OIDs).
Fingerprint
String (read-only)
Default Value: ""
The hex-encoded, 16-byte MD5 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: bc:2a:72:af:fe:58:17:43:7a:5f:ba:5a:7c:90:f7:02
FingerprintSHA1
String (read-only)
Default Value: ""
The hex-encoded, 20-byte SHA-1 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 30:7b:fa:38:65:83:ff:da:b4:4e:07:3f:17:b8:a4:ed:80:be:ff:84
FingerprintSHA256
String (read-only)
Default Value: ""
The hex-encoded, 32-byte SHA-256 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 6a:80:5c:33:a9:43:ea:b0:96:12:8a:64:96:30:ef:4a:8a:96:86:ce:f4:c7:be:10:24:8e:2b:60:9e:f3:59:53
Issuer
String (read-only)
Default Value: ""
The issuer of the certificate. This field contains a string representation of the name of the issuing authority for the certificate.
KeyPassword
String
Default Value: ""
The password for the certificate's private key (if any).
Some certificate stores may individually protect certificates' private keys, separate from the standard protection offered by the StorePassword. This field can be used to read such password-protected private keys.
Note: This property defaults to the value of StorePassword. To clear it, you must set the property to the empty string (""). It can be set at any time, but when the private key's password is different from the store's password, then it must be set before calling PrivateKey.
PrivateKey
String (read-only)
Default Value: ""
The private key of the certificate (if available). The key is provided as PEM/Base64-encoded data.
Note: The PrivateKey may be available but not exportable. In this case, PrivateKey returns an empty string.
PrivateKeyAvailable
boolean (read-only)
Default Value: False
Whether a PrivateKey is available for the selected certificate. If PrivateKeyAvailable is True, the certificate may be used for authentication purposes (e.g., server authentication).
PrivateKeyContainer
String (read-only)
Default Value: ""
The name of the PrivateKey container for the certificate (if available). This functionality is available only on Windows platforms.
PublicKey
String (read-only)
Default Value: ""
The public key of the certificate. The key is provided as PEM/Base64-encoded data.
PublicKeyAlgorithm
String (read-only)
Default Value: ""
The textual description of the certificate's public key algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_DH") or an object identifier (OID) string representing the algorithm.
PublicKeyLength
int (read-only)
Default Value: 0
The length of the certificate's public key (in bits). Common values are 512, 1024, and 2048.
SerialNumber
String (read-only)
Default Value: ""
The serial number of the certificate encoded as a string. The number is encoded as a series of hexadecimal digits, with each pair representing a byte of the serial number.
SignatureAlgorithm
String (read-only)
Default Value: ""
The text description of the certificate's signature algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_MD5RSA") or an object identifier (OID) string representing the algorithm.
Store
String
Default Value: "MY"
The name of the certificate store for the client certificate.
The StoreType field denotes the type of the certificate store specified by Store. If the store is password-protected, specify the password in StorePassword.
Store is used in conjunction with the Subject field to specify client certificates. If Store has a value, and Subject or Encoded is set, a search for a certificate is initiated. Please see the Subject field for details.
Designations of certificate stores are platform dependent.
The following designations are the most common User and Machine certificate stores in Windows:
MY | A certificate store holding personal certificates with their associated private keys. |
CA | Certifying authority certificates. |
ROOT | Root certificates. |
In Java, the certificate store normally is a file containing certificates and optional private keys.
When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).
StoreB
byte[]
Default Value: "MY"
The name of the certificate store for the client certificate.
The StoreType field denotes the type of the certificate store specified by Store. If the store is password-protected, specify the password in StorePassword.
Store is used in conjunction with the Subject field to specify client certificates. If Store has a value, and Subject or Encoded is set, a search for a certificate is initiated. Please see the Subject field for details.
Designations of certificate stores are platform dependent.
The following designations are the most common User and Machine certificate stores in Windows:
MY | A certificate store holding personal certificates with their associated private keys. |
CA | Certifying authority certificates. |
ROOT | Root certificates. |
In Java, the certificate store normally is a file containing certificates and optional private keys.
When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).
StorePassword
String
Default Value: ""
If the type of certificate store requires a password, this field is used to specify the password needed to open the certificate store.
StoreType
int
Default Value: 0
The type of certificate store for this certificate.
The class supports both public and private keys in a variety of formats. When the cstAuto value is used, the class will automatically determine the type. This field can take one of the following values:
0 (cstUser - default) | For Windows, this specifies that the certificate store is a certificate store owned by the current user.
Note: This store type is not available in Java. |
1 (cstMachine) | For Windows, this specifies that the certificate store is a machine store.
Note: This store type is not available in Java. |
2 (cstPFXFile) | The certificate store is the name of a PFX (PKCS#12) file containing certificates. |
3 (cstPFXBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in PFX (PKCS#12) format. |
4 (cstJKSFile) | The certificate store is the name of a Java Key Store (JKS) file containing certificates.
Note: This store type is only available in Java. |
5 (cstJKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in Java Key Store (JKS) format.
Note: This store type is only available in Java. |
6 (cstPEMKeyFile) | The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate. |
7 (cstPEMKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a private key and an optional certificate. |
8 (cstPublicKeyFile) | The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate. |
9 (cstPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a PEM- or DER-encoded public key certificate. |
10 (cstSSHPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains an SSH-style public key. |
11 (cstP7BFile) | The certificate store is the name of a PKCS#7 file containing certificates. |
12 (cstP7BBlob) | The certificate store is a string (binary) representing a certificate store in PKCS#7 format. |
13 (cstSSHPublicKeyFile) | The certificate store is the name of a file that contains an SSH-style public key. |
14 (cstPPKFile) | The certificate store is the name of a file that contains a PPK (PuTTY Private Key). |
15 (cstPPKBlob) | The certificate store is a string (binary) that contains a PPK (PuTTY Private Key). |
16 (cstXMLFile) | The certificate store is the name of a file that contains a certificate in XML format. |
17 (cstXMLBlob) | The certificate store is a string that contains a certificate in XML format. |
18 (cstJWKFile) | The certificate store is the name of a file that contains a JWK (JSON Web Key). |
19 (cstJWKBlob) | The certificate store is a string that contains a JWK (JSON Web Key). |
21 (cstBCFKSFile) | The certificate store is the name of a file that contains a BCFKS (Bouncy Castle FIPS Key Store).
Note: This store type is only available in Java and .NET. |
22 (cstBCFKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in BCFKS (Bouncy Castle FIPS Key Store) format.
Note: This store type is only available in Java and .NET. |
23 (cstPKCS11) | The certificate is present on a physical security key accessible via a PKCS#11 interface.
To use a security key, the necessary data must first be collected using the CertMgr class. The ListStoreCertificates method may be called after setting CertStoreType to cstPKCS11, CertStorePassword to the PIN, and CertStore to the full path of the PKCS#11 DLL. The certificate information returned in the CertList event's CertEncoded parameter may be saved for later use. When using a certificate, pass the previously saved security key information as the Store and set StorePassword to the PIN. Code Example. SSH Authentication with Security Key:
|
99 (cstAuto) | The store type is automatically detected from the input data. This setting may be used with both public and private keys and can detect any of the supported formats automatically. |
SubjectAltNames
String (read-only)
Default Value: ""
Comma-separated lists of alternative subject names for the certificate.
ThumbprintMD5
String (read-only)
Default Value: ""
The MD5 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
ThumbprintSHA1
String (read-only)
Default Value: ""
The SHA-1 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
ThumbprintSHA256
String (read-only)
Default Value: ""
The SHA-256 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
Usage
String (read-only)
Default Value: ""
The text description of UsageFlags.
This value will be one or more of the following strings and will be separated by commas:
- Digital Signature
- Non-Repudiation
- Key Encipherment
- Data Encipherment
- Key Agreement
- Certificate Signing
- CRL Signing
- Encipher Only
If the provider is OpenSSL, the value is a comma-separated list of X.509 certificate extension names.
UsageFlags
int (read-only)
Default Value: 0
The flags that show intended use for the certificate. The value of UsageFlags is a combination of the following flags:
0x80 | Digital Signature |
0x40 | Non-Repudiation |
0x20 | Key Encipherment |
0x10 | Data Encipherment |
0x08 | Key Agreement |
0x04 | Certificate Signing |
0x02 | CRL Signing |
0x01 | Encipher Only |
Please see the Usage field for a text representation of UsageFlags.
This functionality currently is not available when the provider is OpenSSL.
Version
String (read-only)
Default Value: ""
The certificate's version number. The possible values are the strings "V1", "V2", and "V3".
Subject
String
Default Value: ""
The subject of the certificate used for client authentication.
This field will be populated with the full subject of the loaded certificate. When loading a certificate, the subject is used to locate the certificate in the store.
If an exact match is not found, the store is searched for subjects containing the value of the property.
If a match is still not found, the property is set to an empty string, and no certificate is selected.
The special value "*" picks a random certificate in the certificate store.
The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=support@nsoftware.com". Common fields and their meanings are as follows:
Field | Meaning |
CN | Common Name. This is commonly a hostname like www.server.com. |
O | Organization |
OU | Organizational Unit |
L | Locality |
S | State |
C | Country |
E | Email Address |
If a field value contains a comma, it must be quoted.
Encoded
String
Default Value: ""
The certificate (PEM/Base64 encoded). This field is used to assign a specific certificate. The Store and Subject fields also may be used to specify a certificate.
When Encoded is set, a search is initiated in the current Store for the private key of the certificate. If the key is found, Subject is updated to reflect the full subject of the selected certificate; otherwise, Subject is set to an empty string.
EncodedB
byte[]
Default Value: ""
The certificate (PEM/Base64 encoded). This field is used to assign a specific certificate. The Store and Subject fields also may be used to specify a certificate.
When Encoded is set, a search is initiated in the current Store for the private key of the certificate. If the key is found, Subject is updated to reflect the full subject of the selected certificate; otherwise, Subject is set to an empty string.
Constructors
public Certificate();
Creates a instance whose properties can be set. This is useful for use with when generating new certificates.
public Certificate( certificateFile);
Opens CertificateFile and reads out the contents as an X.509 public key.
public Certificate( encoded);
Parses Encoded as an X.509 public key.
public Certificate( storeType, store, storePassword, subject);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, subject, configurationString);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.
ConfigurationString is a newline-separated list of name-value pairs that may be used to modify the default behavior. Possible values include "PersistPFXKey", which shows whether or not the PFX key is persisted after performing operations with the private key. This correlates to the PKCS12_NO_PERSIST_KEY CryptoAPI option. The default value is True (the key is persisted). "Thumbprint" - an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load. When specified, this value is used to select the certificate in the store. This is applicable to the cstUser , cstMachine , cstPublicKeyFile , and cstPFXFile store types. "UseInternalSecurityAPI" shows whether the platform (default) or the internal security API is used when performing certificate-related operations.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, encoded);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will load Encoded as an X.509 certificate and search the opened store for a corresponding private key.
public Certificate( storeType, store, storePassword, subject);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, subject, configurationString);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.
public Certificate( storeType, store, storePassword, encoded);
StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.
After the store has been successfully opened, the class will load Encoded as an X.509 certificate and search the opened store for a corresponding private key.
Header Type
This is an HTTP header as it is received from the server.
Remarks
When a header is received through a Header event, it is parsed into a Header type. This type contains a Field, and its corresponding Value.
Fields
Field
String
Default Value: ""
This field contains the name of the HTTP Header (this is the same case as it is delivered).
Value
String
Default Value: ""
This field contains the Header contents.
Constructors
public Header();
public Header( field, value);
Config Settings (SMIME Class)
The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.SMIME Config Settings
Note: When signing, this configuration setting may be used only when DetachedSignature is False.
Note: This configuration setting may be used only when the UseCryptoAPI is True.
The default value is True.
The default value for IncludeHeaders is False.
The default value for IncludeInternalHeaders is True.
If no value is specified and a value cannot be automatically determined, the default value 7bit will be used.
Note: This setting is applicable only when calling Sign or SignAndEncrypt and DetachedSignature is True.
If no value is specified and a value cannot be automatically determined, the default value text/plain; charset="iso-8859-1" will be used.
Note: This setting is applicable only when calling Sign or SignAndEncrypt and DetachedSignature is True.
- "SHA1"
- "SHA224"
- "SHA256" (default)
- "SHA384"
- "SHA512"
- "RIPEMD160"
- "MD2"
- "MD5"
- "MD5SHA1"
- "SHA1"
- "SHA224"
- "SHA256" (default)
- "SHA384"
- "SHA512"
- "RIPEMD160"
- "MD2"
- "MD5"
- "MD5SHA1"
The default value for ParseInternalHeaders is True.
This configuration setting may be set to the entire blob of the public certificate the class should use to select the correct recipient-encrypted key for decryption.
This configuration setting may be set to the file that contains the public certificate the class should use to select the correct recipient-encrypted key for decryption.
- 0 (issuerAndSerialNumber - default)
- 1 (subjectKeyIdentifier)
Note: When subjectKeyIdentifier is selected, the recipient's encryption certificate must contain the subjectKeyIdentifier extension.
- 0 (issuerAndSerialNumber - default)
- 1 (subjectKeyIdentifier)
Note: When subjectKeyIdentifier is selected, the signing certificate must contain the subjectKeyIdentifier extension.
The default value is False, and the name of the algorithm is used. Set this to True to use the object identifiers instead.
Note: Compression will be impossible in this case.
If set to False (the default), the class will use its internal S/MIME engine.
If set to True, the class will verify that the issuer(s) of the signer certificate are valid and trusted on the system.
If set to False (default), the certificate chain is not validated.
Note: This setting does not affect whether the digital signature of the signed message is verified. This setting affects only whether the trust and validity of the signer certificate chain is evaluated.
Base Config Settings
In some non-GUI applications, an invalid message loop may be discovered that will result in errant behavior. In these cases, setting GUIAvailable to false will ensure that the class does not attempt to process external events.
- Product: The product the license is for.
- Product Key: The key the license was generated from.
- License Source: Where the license was found (e.g., RuntimeLicense, License File).
- License Type: The type of license installed (e.g., Royalty Free, Single Server).
- Last Valid Build: The last valid build number for which the license will work.
This setting only works on these classes: AS3Receiver, AS3Sender, Atom, Client(3DS), FTP, FTPServer, IMAP, OFTPClient, SSHClient, SCP, Server(3DS), Sexec, SFTP, SFTPServer, SSHServer, TCPClient, TCPServer.
Setting this configuration setting to true tells the class to use the internal implementation instead of using the system security libraries.
This setting is set to false by default on all platforms.
Trappable Errors (SMIME Class)
SMIME Errors
10191 | Invalid index (RecipientIndex). |
10192 | Message decoding error (code). |
10193 | Unexpected message type. |
10194 | Unsupported hashing/signing algorithm. |
10195 | The message does not have any signers. |
10196 | The message signature could not be verified. |
10197 | Could not locate a suitable decryption certificate. |
10198 | The signer certificate could not be found. |
10199 | No signing certificate was supplied for signing the message. |
10201 | The specified certificate was not the one required. |
10202 | The specified certificate could not be found. |
10221 | Could not acquire CSP. |
10222 | Type validation error. |
10223 | Unsupported key size. |
10224 | Unrecognized Content-Type object identifier. |
10225 | Unrecognized public key format. |
10226 | No choices specified. |
10228 | Must specify output stream. |
10280 | Invalid part index. |
10281 | Unknown MIME type. |
10283 | No MIME-boundary found. |
10280 | Error decoding certificate. |