Class Mime
- All Implemented Interfaces:
AutoCloseable
Build, parse, modify, serialize, secure, and inspect MIME and S/MIME data.
Mime provides low-level MIME and S/MIME handling for
applications that need direct control over MIME structure, headers, body
content, encodings, multipart relationships, attachments, and PKCS7/CMS
security layers. It can load, create, inspect, modify, serialize, and save
MIME messages; build multipart structures; manage headers and content-transfer
encodings; extract attachments; convert MIME to and from XML; and sign,
verify, encrypt, decrypt, or unwrap S/MIME content.
Create and load MIME
Build MIME content programmatically or load existing MIME from strings, files, byte data, or other application sources.
Headers and body content
Read, add, replace, or remove MIME headers, set body content, and control content types, charsets, and transfer encodings.
Multipart structures
Create and inspect multipart MIME trees such as mixed, alternative, related, signed, encrypted, and nested MIME structures.
Attachments and parts
Add, locate, extract, remove, or inspect MIME parts and attachments, including filenames and encoded body data.
S/MIME security
Sign, verify, encrypt, decrypt, unwrap, and inspect PKCS7/CMS S/MIME layers using certificates and private keys.
Serialization and XML
Emit MIME text, save MIME to files, or convert MIME to and from XML for structured inspection, transformation, or storage.
Common pattern:
Use Mime when an application needs low-level control
over MIME parts, headers, encodings, multipart layout, or S/MIME security.
For ordinary email composition and message-level operations, use
Email; use Mime when you need to work
closer to the raw MIME structure.
Initial state: A new Mime object has no headers or child parts. Its
string serialization consists only of the blank header/body separator (CRLF CRLF) until
content is added.
MIME parsing is semantic, not byte-preserving. Loading and reserializing can unfold
headers, normalize parameter quoting and transfer encodings, use CRLF for generated headers and
multipart framing, and discard multipart preamble or epilogue text. Use byte-oriented methods such
as and loadMimeBd(BinData) when
arbitrary 8-bit bytes or embedded NUL bytes must be preserved.
getMimeBd(BinData)
For an extended overview, see Mime Class Overview.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidComputes the byte length of the current entity's serialized MIME body and adds or updates itsContent-Lengthheader.voidaddDecryptCert(Cert cert)Addscertto the internal collection of certificates available for S/MIME decryption.voidaddDetachedSignature(Cert cert)Creates an S/MIME detached signature usingcert.voidaddDetachedSignature2(Cert cert, boolean transferHeaderFields)Creates the same detachedmultipart/signedstructure as.addDetachedSignature(Cert)voidaddDetachedSignaturePk(Cert cert, PrivateKey privateKey)Creates a detached S/MIME signature usingcertas the signer certificate andprivateKeyas its associated private key.voidaddDetachedSignaturePk2(Cert cert, PrivateKey privateKey, boolean transferHeaderFields)Creates a detached S/MIME signature using the certificate incertand the corresponding private key inprivateKey.voidaddEncryptCert(Cert cert)Addscertto the internal recipient-certificate list used by.encryptN()voidaddHeaderField(String name, String value)Appends a new header field named bynamewith the value invalue.voidaddPfxSourceBd(BinData bd, String password)Adds the PKCS #12/PFX bytes inbdto the internal collection of credential sources used by later S/MIME decryption operations.voidaddPfxSourceFile(String pfxFilePath, String password)Adds the PFX/P12 file at the local filesystem path inpfxFilePathto the internal collection of credential sources used by later S/MIME decryption operations.voidappendPart(Mime mime)Appends a copy ofmimeas the last direct child.voidappendPartFromFile(String filename)Reads the local file atfilename, creates an attachment part, and appends it.Parses the current part's decoded body as ASN.1 DER and returns an XML representation of the ASN.1 structure.voidClears the internal recipient-certificate list populated by.addEncryptCert(Cert)booleanReturnstrueif the currently visible MIME tree contains a CMS/PKCS #7 encrypted entity.booleanReturnstrueif the currently visible MIME tree contains a complete detached or opaque CMS/PKCS #7 signed entity.voidRecursively converts every part whoseContent-Transfer-Encodingis8bitorbinarytobase64.voidWraps the current entity in a new outermultipart/alternativeentity.voidWraps the current entity in a new outermultipart/mixedentity.voidconvertToSigned(Cert cert)Creates an opaque (attached) S/MIME signature usingcert.voidconvertToSignedPk(Cert cert, PrivateKey privateKey)Creates an opaque (attached) S/MIME signature usingcertas the signer certificate andprivateKeyas its associated private key.voiddecrypt()Decrypts the current CMS/PKCS #7 encrypted MIME entity and replaces it with the recovered MIME content.voiddecrypt2(Cert cert, PrivateKey privateKey)Decrypts the current CMS/PKCS #7 encrypted MIME entity using the certificate incertand its associated private key inprivateKey.voiddecryptUsingCert(Cert cert)Decrypts the current CMS/PKCS #7 encrypted MIME entity usingcert.voiddecryptUsingPfxFile(String pfxFilePath, String pfxPassword)Decrypts the current CMS/PKCS #7 encrypted MIME entity using certificates and private keys from the PFX/P12 file at the local filesystem path inpfxFilePath.voidEncrypts the current MIME entity for the recipient certificate incertand replaces it with CMS/PKCS #7 encrypted S/MIME.voidencryptN()Encrypts the current MIME entity for every certificate previously added with.addEncryptCert(Cert)voidReplaces the contents ofbinDatwith the decoded body bytes of the current part.Returns the decoded body as text.Returns the current part's transfer-encoded body text without decoding Base64 or quoted-printable.Gets or sets the raw boundary token used by a multipart MIME entity.Gets or sets thecharsetparameter of theContent-Typeheader field.Gets or sets a JSON string containing advanced CMS/PKCS #7 signing and validation options.Gets or sets the MIME media type of the current part, excluding all parameters.Returns the current local date and time formatted as an Internet message date, including the numeric UTC offset.voidgetDecryptCertInfo(JsonObject certInfo)Examines the current encrypted S/MIME entity and writes recipient-certificate identifiers to theJsonObjectincertInfo.Gets or sets the disposition value from theContent-Dispositionheader field, excluding parameters such asfilename.Gets or sets the value of theContent-Transfer-Encodingheader field for the current part.Returns the complete serialized body of the current MIME entity.Returns the complete serialized header section of the current MIME entity.Gets or sets thefilenameparameter of theContent-Dispositionheader field.getHeaderField(String fieldName)Returns the value of the first header field whose name matchesfieldNamecase-insensitively.getHeaderFieldAttribute(String name, String attrName)Returns an attribute value parsed from the first header field named byname.getHeaderFieldName(int index)Returns the name of the header-field occurrence at zero-basedindex.getHeaderFieldValue(int index)Returns the unfolded value of the header-field occurrence at zero-basedindex.voidgetLastJsonData(JsonObject json)Copies structured details from the most recent operation intojsonwhen such details are available.Gets or sets themicalgparameter of amultipart/signedContent-Typeheader field.getMime()Serializes and returns the complete MIME entity, including headers, body, multipart boundaries, and all descendants.voidSerializes the complete MIME entity and appends its bytes tobindat.voidgetMimeSb(StringBuilder sb)Serializes the complete MIME entity and appends it tosb.getName()Gets or sets thenameparameter of theContent-Typeheader field.intReturns the number of recipient or decryption certificates currently recorded by the most recent S/MIME encryption, decryption, or security-unwrapping operation.intReturns the number of header-field occurrences in the current part.intReturns the number of direct child parts.intReturns the number of signer certificates currently recorded by the most recent S/MIME signing, signature-verification, or security-unwrapping operation.Gets or sets the hash algorithm used by RSAES-OAEP when encrypting the CMS content-encryption key.Gets or sets the hash algorithm used by the MGF1 mask generation function within RSAES-OAEP.booleanSelects the RSA key-transport padding used when creating encrypted MIME.Gets or sets the symmetric content-encryption algorithm used when creating CMS/PKCS #7 encrypted MIME.intGets or sets the content-encryption key length, in bits, used when creating CMS/PKCS #7 encrypted MIME.Gets or sets theprotocolparameter of theContent-Typeheader field.getSignatureSigningTimeStr(int index)Returns the CMSsigningTimesigned attribute for the signer at zero-basedindex, formatted as an RFC 822-style date string in GMT.Gets or sets the RSA signature scheme used when creating CMS/PKCS #7 signed MIME.Gets or sets the message-digest algorithm used when creating CMS/PKCS #7 signatures.getStructure(String fmt)Returns a concise MIME-tree summary.Gets or sets a semicolon-delimited or implementation-specific option string used for uncommon compatibility requirements.booleanControls whetheradds informative header fields describing the security layers removed.unwrapSecurity()booleanControls whether Chilkat uses the conventional multipart preamble textThis is a multi-part message in MIME format.when serializing a multipart entity.booleanControls whether newly created S/MIME media types use the historicalx-pkcs7names.getXml()Converts the MIME tree to Chilkat's XML representation and returns it as a string.booleanhasSignatureSigningTime(int index)Returnstrueif the signer at zero-basedindexhas a CMSsigningTimesigned attribute.booleanbooleanReturnstruewhen the current part's disposition value isattachment, matched case-insensitively.booleanisAudio()booleanReturnstruewhen the current MIME entity is a CMS/PKCS #7 encrypted S/MIME wrapper.booleanisHtml()booleanisImage()booleanbooleanbooleanbooleanbooleanbooleanisSigned()Returnstruewhen the current MIME entity is a complete CMS/PKCS #7 signed S/MIME wrapper, including detachedmultipart/signedand opaque signed-data forms.booleanisText()booleanisVideo()booleanisXml()Returnstrueonly fortext/xmlorapplication/xml.voidlastDecryptCert(int index, Cert cert)Loads intocertthe decryption certificate at zero-basedindexfrom the most recent successful decryption or security-unwrapping operation.voidlastSignerCert(int index, Cert cert)Loads intocertthe signer certificate at zero-basedindexfrom the most recent successful signature-verification or security-unwrapping operation.voidParses the complete MIME text inmimeMsgand replaces the current object's headers, body, and multipart tree.voidloadMimeBd(BinData bindat)Parses complete MIME bytes frombindatand replaces the current MIME on success.voidloadMimeFile(String fileName)Reads and parses the complete MIME entity from the local file atfileName.voidloadMimeSb(StringBuilder sb)Parses complete MIME text fromsband replaces the current MIME on success.voidReconstructs a MIME tree from Chilkat's MIME XML inxml.voidloadXmlFile(String fileName)Reads Chilkat MIME XML from the local file atfileNameand reconstructs the MIME tree.voidnewMessageRfc822(Mime mimeObject)Clears the current object and initializes it asmessage/rfc822.voidInitializes an emptymultipart/alternativeentity.voidInitializes an emptymultipart/mixedentity.voidInitializes an emptymultipart/relatedentity.voidProvides live access to the direct child at zero-basedindexthroughsubPart.voidpartsToFiles(String path, StringTable st)Recursively traverses the MIME tree and saves each part having a nonemptyfilenameparameter to the existing directory inpath.voidremoveHeaderField(String fieldName, boolean bAllOccurrences)Removes fields whose name matchesfieldNamecase-insensitively.voidremovePart(int index)Removes the direct child at zero-basedindex.voidWrites the decoded body bytes of the current part to the local path infilename.voidSerializes the complete MIME entity and writes it to the local path infilename, including headers, body, multipart boundaries, and all descendants.voidWrites Chilkat's MIME XML representation to the local path infilename.voidSets the current part's body fromstrwhile preserving existing content headers such asContent-Type,charset, andContent-Transfer-Encoding.voidSets the decoded body bytes frombd, changesContent-Transfer-Encodingtobase64, and preserves the bytes exactly.voidsetBodyFromEncoded(String encoding, String str)Sets the body from transfer-encoded text.voidsetBodyFromFile(String fileName)Reads the local file atfileNameand replaces the current part's body and content headers according to the filename extension.voidsetBodyFromHtml(String str)Setsstras HTML and changes the media type totext/html.voidsetBodyFromPlainText(String str)Setsstras plain text.voidsetBodyFromXml(String str)Setsstras XML, changes the media type totext/xml, and selects a transfer encoding appropriate for the text.voidsetBoundary(String value)Sets theBoundaryproperty; seegetBoundary().voidsetCharset(String value)Sets theCharsetproperty; seegetCharset().voidsetCmsOptions(String value)Sets theCmsOptionsproperty; seegetCmsOptions().voidsetContentType(String value)Sets theContentTypeproperty; seegetContentType().voidsetDisposition(String value)Sets theDispositionproperty; seegetDisposition().voidsetEncoding(String value)Sets theEncodingproperty; seegetEncoding().voidsetFilename(String value)Sets theFilenameproperty; seegetFilename().voidsetHeaderField(String name, String value)Sets one header field named byname.voidSets theMicalgproperty; seegetMicalg().voidSets theNameproperty; seegetName().voidsetOaepHash(String value)Sets theOaepHashproperty; seegetOaepHash().voidsetOaepMgfHash(String value)Sets theOaepMgfHashproperty; seegetOaepMgfHash().voidsetOaepPadding(boolean value)Sets theOaepPaddingproperty; seegetOaepPadding().voidsetPkcs7CryptAlg(String value)Sets thePkcs7CryptAlgproperty; seegetPkcs7CryptAlg().voidsetPkcs7KeyLength(int value)Sets thePkcs7KeyLengthproperty; seegetPkcs7KeyLength().voidsetProtocol(String value)Sets theProtocolproperty; seegetProtocol().voidsetSigningAlg(String value)Sets theSigningAlgproperty; seegetSigningAlg().voidsetSigningHashAlg(String value)Sets theSigningHashAlgproperty; seegetSigningHashAlg().voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsetUnwrapExtras(boolean value)Sets theUnwrapExtrasproperty; seegetUnwrapExtras().voidsetUseMmDescription(boolean value)Sets theUseMmDescriptionproperty; seegetUseMmDescription().voidsetUseXPkcs7(boolean value)Sets theUseXPkcs7property; seegetUseXPkcs7().voidsetVerifyCert(Cert cert)Suppliescertas a signer-certificate fallback for subsequent signature verification.voidRemoves supported S/MIME security layers and restores the underlying MIME content.voidurlEncodeBody(String charset)Replaces the current body with anapplication/x-www-form-urlencoded-style representation using the character set named bycharset.voiduseCertVault(XmlCertVault vault)Setsvaultas the certificate vault used to locate certificates and private keys for S/MIME encryption, decryption, signing, and verification.voidverify()Verifies the current CMS/PKCS #7 signed MIME entity and removes the signature wrapper.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Mime
public Mime()Creates a newMimeobject.
-
-
Method Details
-
getBoundary
Gets or sets the raw boundary token used by a multipart MIME entity. Do not include surrounding quotation marks.Content-Type: multipart/mixed; boundary="example-boundary"
For this example,
Boundaryisexample-boundary. Chilkat automatically quotes the parameter when the token contains characters such as spaces or semicolons. Normally automatic. Methods such as,newMultipartMixed(), andnewMultipartAlternative()generate a nonempty boundary. Caller-supplied boundaries are not validated. Chilkat does not detect collisions with body text. An empty value is permitted but produces invalid multipart delimiters, and supplying quotation marks as part of the property value causes those quotation marks to become part of the boundary. The property can also be set on a nonmultipart entity, where it is simply added as anewMultipartRelated()Content-Typeparameter.- Returns:
- the value of the
Boundaryproperty
-
setBoundary
Sets theBoundaryproperty; seegetBoundary().- Parameters:
value- the new value (notnull)
-
getCharset
Gets or sets thecharsetparameter of theContent-Typeheader field.Content-Type: text/plain; charset=utf-8
Changing this property preserves the media type and other parameters. Setting it when no
Content-Typeexists creates aContent-Typefield, although the media type remains empty untilis set. Charset versus transfer encoding. The charset identifies how text characters are represented as bytes.getContentType()controls the MIME transport representation of those bytes. Empty-string behavior. SettinggetEncoding()Charsetto an empty string does not remove the parameter. It selects the platform default ANSI charset; on Windows this is typicallywindows-1252.- Returns:
- the value of the
Charsetproperty
-
setCharset
Sets theCharsetproperty; seegetCharset().- Parameters:
value- the new value (notnull)
-
getCmsOptions
Gets or sets a JSON string containing advanced CMS/PKCS #7 signing and validation options. The default is an empty string, which selects normal behavior. A valid empty JSON object may also be supplied as{}.Unknown JSON members are retained but ignored. Malformed JSON is normalized to
{}. This property is intended for specialized interoperability requirements; applications should leave it empty unless a documented option is specifically needed.- Returns:
- the value of the
CmsOptionsproperty
-
setCmsOptions
Sets theCmsOptionsproperty; seegetCmsOptions().- Parameters:
value- the new value (notnull)
-
getContentType
Gets or sets the MIME media type of the current part, excluding all parameters. Supply a value such astext/plain,text/html,application/pdf, ormultipart/mixed; do not includecharset,boundary, or other parameters in this property.Changing the media type preserves the existing
charsetand unrecognized parameters, but may remove parameters that are specific to the previous media type, such asformat=flowed. Setting an empty string leaves an empty media type and can therefore produce an invalid-looking header if other parameters remain.Classification methods use this value. Methods such as
,isText(), andisImage()classify the media type stored here. Parameters must be set through their dedicated properties or header attributes, not appended toisMultipart()ContentType.- Returns:
- the value of the
ContentTypeproperty
-
setContentType
Sets theContentTypeproperty; seegetContentType().- Parameters:
value- the new value (notnull)
-
getCurrentDateTime
Returns the current local date and time formatted as an Internet message date, including the numeric UTC offset. For example:Fri, 21 Nov 1997 09:55:06 -0600
- Returns:
- the value of the
CurrentDateTimeproperty (read-only)
-
getDisposition
Gets or sets the disposition value from theContent-Dispositionheader field, excluding parameters such asfilename.Content-Disposition: attachment; filename="report.pdf"
Changing this property preserves an existing
filenameparameter. Typical values areattachmentandinline.- Returns:
- the value of the
Dispositionproperty
-
setDisposition
Sets theDispositionproperty; seegetDisposition().- Parameters:
value- the new value (notnull)
-
getEncoding
Gets or sets the value of theContent-Transfer-Encodingheader field for the current part. Common values includebase64,quoted-printable,7bit,8bit, andbinary. Transfer encoding is not compression. It determines how the body bytes are represented in serialized MIME.returns the transfer-encoded form, whilegetBodyEncoded(),getBodyBd(BinData), andGetBodyBinaryreturn or save decoded bytes.saveBody(String)- Returns:
- the value of the
Encodingproperty
-
setEncoding
Sets theEncodingproperty; seegetEncoding().- Parameters:
value- the new value (notnull)
-
getFilename
Gets or sets thefilenameparameter of theContent-Dispositionheader field. The value is a receiver-facing filename, not a local filesystem path.Changing this property preserves the disposition value but removes other
Content-Dispositionparameters such assize. Setting an empty string removes thefilenameparameter.International filenames. When setting a non-ASCII filename, Chilkat emits an RFC 2047 encoded-word in
filename=. When reading a header containing bothfilename=andfilename*=, this property returnsfilename=. Useto retrieve the rawgetHeaderFieldAttribute(String, String)filename*value.- Returns:
- the value of the
Filenameproperty
-
setFilename
Sets theFilenameproperty; seegetFilename().- Parameters:
value- the new value (notnull)
-
getMicalg
Gets or sets themicalgparameter of amultipart/signedContent-Typeheader field.Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="example-boundary"
The parameter advertises the message-digest algorithm used by the detached signature. SigningHashAlg is authoritative. When a detached signature is created,
selects the digest and Chilkat replaces any conflictinggetSigningHashAlg()Micalgvalue with the corresponding MIME token, such assha-1,sha-256,sha-384, orsha-512. SettingMicalgalone does not select the cryptographic digest.- Returns:
- the value of the
Micalgproperty
-
setMicalg
Sets theMicalgproperty; seegetMicalg().- Parameters:
value- the new value (notnull)
-
getName
Gets or sets thenameparameter of theContent-Typeheader field. For attachments,is generally the primary receiver-facing name.getFilename()Setting a non-ASCII value causes Chilkat to emit an RFC 2047 encoded-word in the
name=parameter. Setting this property when no media type exists creates aContent-Typefield with an empty media type.- Returns:
- the value of the
Nameproperty
-
setName
Sets theNameproperty; seegetName().- Parameters:
value- the new value (notnull)
-
getNumDecryptCerts
public int getNumDecryptCerts()Returns the number of recipient or decryption certificates currently recorded by the most recent S/MIME encryption, decryption, or security-unwrapping operation. A new object returns0. A successful single-recipientrecordsencrypt(Cert)1, and successful decryption records the certificate whose private key was used.Use
with a zero-based index to retrieve a recorded certificate. This is a result count; it is not the number of PFX sources or decryption certificates configured on the object.lastDecryptCert(int, Cert)- Returns:
- the value of the
NumDecryptCertsproperty (read-only)
-
getNumHeaderFields
public int getNumHeaderFields()Returns the number of header-field occurrences in the current part. Duplicate names count separately and retain their order. Valid indexes range from0throughNumHeaderFields - 1for use withandgetHeaderFieldName(int).getHeaderFieldValue(int)During MIME parsing, duplicate ordinary fields are retained. Duplicate
Content-Typefields are collapsed, with the last value taking effect.- Returns:
- the value of the
NumHeaderFieldsproperty (read-only)
-
getNumParts
public int getNumParts()Returns the number of direct child parts. It does not include deeper descendants. Iterate from0throughNumParts - 1and callto traverse the tree.partAt(int, Mime)The object returned by
PartAtprovides live access to the stored child. Modifying that returned object modifies the parent MIME tree.- Returns:
- the value of the
NumPartsproperty (read-only)
-
getNumSignerCerts
public int getNumSignerCerts()Returns the number of signer certificates currently recorded by the most recent S/MIME signing, signature-verification, or security-unwrapping operation. A new object returns0. A single-certificate signing method records1;andverify()replace the count with the signer results from that operation.unwrapSecurity()A failed call to
clears the signer results and sets this property toverify()0. Usewith a zero-based index to retrieve a recorded signer certificate.lastSignerCert(int, Cert)- Returns:
- the value of the
NumSignerCertsproperty (read-only)
-
getOaepHash
Gets or sets the hash algorithm used by RSAES-OAEP when encrypting the CMS content-encryption key. Supported values aresha1,sha256,sha384, andsha512. The default issha256. An empty or unrecognized value leaves the current valid setting unchanged.This property is used only when
isgetOaepPadding()true. It is independent of; for example, OAEP may use SHA-256 while MGF1 uses SHA-1.getOaepMgfHash()- Returns:
- the value of the
OaepHashproperty
-
setOaepHash
Sets theOaepHashproperty; seegetOaepHash().- Parameters:
value- the new value (notnull)
-
getOaepMgfHash
Gets or sets the hash algorithm used by the MGF1 mask generation function within RSAES-OAEP. Supported values aresha1,sha256,sha384, andsha512. The default issha256. An empty or unrecognized value leaves the current valid setting unchanged.This property is used only when
isgetOaepPadding()trueand is independent of.getOaepHash()- Returns:
- the value of the
OaepMgfHashproperty
-
setOaepMgfHash
Sets theOaepMgfHashproperty; seegetOaepMgfHash().- Parameters:
value- the new value (notnull)
-
getOaepPadding
public boolean getOaepPadding()Selects the RSA key-transport padding used when creating encrypted MIME. The default isfalse, which uses RSAES-PKCS1-v1_5. Set totrueto use RSAES-OAEP. Scope. This setting protects the symmetric content-encryption key for an RSA recipient. It does not change the symmetric content algorithm selected by.getPkcs7CryptAlg()- Returns:
- the value of the
OaepPaddingproperty
-
setOaepPadding
public void setOaepPadding(boolean value)Sets theOaepPaddingproperty; seegetOaepPadding().- Parameters:
value- the new value
-
getPkcs7CryptAlg
Gets or sets the symmetric content-encryption algorithm used when creating CMS/PKCS #7 encrypted MIME. Supported input values areaes,aes-gcm,des,3des, andrc2. The default isaes. Theaes-gcmoption was added in version 10.0.0.The getter returns normalized names: after setting
aes-gcmit returnsaes, and after setting3desit returnsdes. The generated CMS data nevertheless uses AES-GCM or 3DES-CBC respectively.Hybrid encryption. S/MIME encrypts the MIME content with a symmetric content-encryption key. The recipient certificate then protects that content-encryption key. This property selects the symmetric algorithm;
selects its key length.getPkcs7KeyLength()- Returns:
- the value of the
Pkcs7CryptAlgproperty
-
setPkcs7CryptAlg
Sets thePkcs7CryptAlgproperty; seegetPkcs7CryptAlg().- Parameters:
value- the new value (notnull)
-
getPkcs7KeyLength
public int getPkcs7KeyLength()Gets or sets the content-encryption key length, in bits, used when creating CMS/PKCS #7 encrypted MIME. The default is128.Because this property may be set before
, the setter accepts the union of key lengths that can be valid for any supported symmetric algorithm:getPkcs7CryptAlg()40,56,64,128,192, and256. A value outside this set is rejected and the previous value is retained.Algorithm Normal key lengths
aesoraes-gcm128,192, or2563des192des40rc240,56,64, or128Set both properties before encrypting. The property setter rejects only lengths that cannot be valid for any supported algorithm. Applications should select the algorithm and its appropriate key length before calling
orencrypt(Cert).encryptN()- Returns:
- the value of the
Pkcs7KeyLengthproperty
-
setPkcs7KeyLength
public void setPkcs7KeyLength(int value)Sets thePkcs7KeyLengthproperty; seegetPkcs7KeyLength().- Parameters:
value- the new value
-
getProtocol
Gets or sets theprotocolparameter of theContent-Typeheader field. This parameter is commonly used bymultipart/signedto identify the media type of the detached signature part.Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="example-boundary"
For this example,
Protocolisapplication/pkcs7-signature.- Returns:
- the value of the
Protocolproperty
-
setProtocol
Sets theProtocolproperty; seegetProtocol().- Parameters:
value- the new value (notnull)
-
getSigningAlg
Gets or sets the RSA signature scheme used when creating CMS/PKCS #7 signed MIME. The default and normalized PKCS #1 v1.5 value isPKCS1-V1_5. Set the property toRSASSA-PSSorpssto use RSASSA-PSS; the getter returnsRSASSA-PSS.An empty or unrecognized value selects
PKCS1-V1_5. This setting applies only when the signing private key is RSA. It does not select the signature scheme for EC or DSA keys. The property controls signature creation and is not updated during verification; useto inspect a verified signature.getLastJsonData(JsonObject)- Returns:
- the value of the
SigningAlgproperty
-
setSigningAlg
Sets theSigningAlgproperty; seegetSigningAlg().- Parameters:
value- the new value (notnull)
-
getSigningHashAlg
Gets or sets the message-digest algorithm used when creating CMS/PKCS #7 signatures. The default issha256. Supported values aresha1,sha256,sha384,sha512,md5, andmd2. Names are case-insensitive and are returned in lowercase.An empty or unrecognized value selects
sha1. This property controls signature creation only and is not changed when a signature is verified. After verification, callto inspect the digest algorithm found in the signed data.getLastJsonData(JsonObject)Security guidance. Use a SHA-2 algorithm such as
sha256unless interoperability with a legacy system requires otherwise. MD2, MD5, and SHA-1 are retained for compatibility with older signed messages. Because invalid input falls back to SHA-1, applications should set this property to a known supported value.- Returns:
- the value of the
SigningHashAlgproperty
-
setSigningHashAlg
Sets theSigningHashAlgproperty; seegetSigningHashAlg().- Parameters:
value- the new value (notnull)
-
getUncommonOptions
Gets or sets a semicolon-delimited or implementation-specific option string used for uncommon compatibility requirements. The default is the empty string, and normal applications should leave it empty. Options placed here may be version-specific and should be used only when directed by Chilkat documentation or support.- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
getUnwrapExtras
public boolean getUnwrapExtras()Controls whetheradds informative header fields describing the security layers removed. The default isunwrapSecurity()true.Header Example value
X-NumPartsSigned1X-SignaturesValidyesX-NumPartsEncrypted1X-DecryptedyesSet to
falsewhen the application requires the unwrapped MIME without these additional status headers.- Returns:
- the value of the
UnwrapExtrasproperty
-
setUnwrapExtras
public void setUnwrapExtras(boolean value)Sets theUnwrapExtrasproperty; seegetUnwrapExtras().- Parameters:
value- the new value
-
getUseMmDescription
public boolean getUseMmDescription()Controls whether Chilkat uses the conventional multipart preamble textThis is a multi-part message in MIME format.when serializing a multipart entity. The default isfalse. The preamble is meaningful only when the multipart has content and is ignored by MIME-aware readers.- Returns:
- the value of the
UseMmDescriptionproperty
-
setUseMmDescription
public void setUseMmDescription(boolean value)Sets theUseMmDescriptionproperty; seegetUseMmDescription().- Parameters:
value- the new value
-
getUseXPkcs7
public boolean getUseXPkcs7()Controls whether newly created S/MIME media types use the historicalx-pkcs7names.Value Generated media types
true(default)application/x-pkcs7-mimeandapplication/x-pkcs7-signaturefalseapplication/pkcs7-mimeandapplication/pkcs7-signatureFor detached signatures, the selected signature media type is used both for the outer
protocolparameter and for the signature part. For opaque signed or encrypted MIME, it controls theapplication/...pkcs7-mimecontent type.Interoperability. The
x-forms are widely encountered in existing S/MIME messages. Chilkat recognizes both naming forms.- Returns:
- the value of the
UseXPkcs7property
-
setUseXPkcs7
public void setUseXPkcs7(boolean value)Sets theUseXPkcs7property; seegetUseXPkcs7().- Parameters:
value- the new value
-
addContentLength
public void addContentLength()Computes the byte length of the current entity's serialized MIME body and adds or updates itsContent-Lengthheader. The count is based on the transfer-encoded serialized body, not the decoded payload.For a multipart entity, the count includes boundary delimiter lines, child headers, child bodies, and the closing boundary. Only the current entity's header is updated; child parts do not receive
Content-Lengthfields. Repeated calls recompute the value and leave a single header occurrence. -
addDecryptCert
Addscertto the internal collection of certificates available for S/MIME decryption. The certificate must have access to its corresponding private key. Call this method once for each candidate certificate.The collection is searched by
anddecrypt(). Other ways to provide decryption credentials includeunwrapSecurity(),addPfxSourceFile(String, String), andaddPfxSourceBd(BinData, String).useCertVault(XmlCertVault)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addDetachedSignature
Creates an S/MIME detached signature usingcert. The certificate itself must have access to its private key. On success, the current object becomes amultipart/signedentity with two direct children:Part Contents
First The original MIME entity being signed.
Second The CMS/PKCS #7 signature data, normally named
smime.p7s.selects the digest and generatedgetSigningHashAlg()micalgparameter. For RSA keys,selects PKCS #1 v1.5 or RSASSA-PSS.getSigningAlg()selects the signature media-type spelling.getUseXPkcs7()Private-key requirement. Adding a matching PFX source does not supply a missing signing key for a public-only
Cert. Load the private key intocertor use. Signing an already signed MIME. Calling this method again creates a new outeraddDetachedSignaturePk(Cert, PrivateKey)multipart/signedlayer. It does not add another signer to the existing CMS signer-information set.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addDetachedSignature2
Creates the same detachedmultipart/signedstructure as.addDetachedSignature(Cert)certis the signing certificate and must have access to its private key.transferHeaderFieldsHeader placementfalseExisting message header fields, such asSubjectandFrom, remain on the first signed content part. The new outer multipart has no copies of those fields.trueExisting message header fields are moved to the new outermultipart/signedentity and removed from the first content part.- Parameters:
cert- thecertargument (notnull)transferHeaderFields- thetransferHeaderFieldsargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addDetachedSignaturePk
Creates a detached S/MIME signature usingcertas the signer certificate andprivateKeyas its associated private key. Use this method when the certificate and private key are supplied separately.On success, the current object becomes the same two-part
multipart/signedstructure described by.addDetachedSignature(Cert),getSigningHashAlg(), andgetSigningAlg()control the generated signature.getUseXPkcs7()- Parameters:
cert- thecertargument (notnull)privateKey- theprivateKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addDetachedSignaturePk2
public void addDetachedSignaturePk2(Cert cert, PrivateKey privateKey, boolean transferHeaderFields)Creates a detached S/MIME signature using the certificate incertand the corresponding private key inprivateKey.transferHeaderFieldscontrols placement of the existing message header fields:transferHeaderFieldsHeader placementfalseHeaders remain on the first signed content part.trueHeaders are moved to the new outermultipart/signedentity and removed from the first content part.This is the separate-private-key counterpart of
.addDetachedSignature2(Cert, boolean)- Parameters:
cert- thecertargument (notnull)privateKey- theprivateKeyargument (notnull)transferHeaderFields- thetransferHeaderFieldsargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addEncryptCert
Addscertto the internal recipient-certificate list used by. Call this method once for each intended recipient. Encryption uses the public key in each certificate, so recipient private keys are not required at encryption time.encryptN()Call
to empty the list.clearEncryptCerts()- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addHeaderField
Appends a new header field named bynamewith the value invalue. Existing fields having the same case-insensitive name are preserved. An emptyvaluecreates a legal empty-valued field.Chilkat converts spaces in a header name to hyphens, removes embedded CR and LF characters from the value to prevent header injection, and folds long values when serializing.
Replacing versus appending. Use
to remove all existing occurrences and set one replacement value.setHeaderField(String, String)- Parameters:
name- thenameargument (notnull)value- thevalueargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxSourceBd
Adds the PKCS #12/PFX bytes inbdto the internal collection of credential sources used by later S/MIME decryption operations.passwordis the password protecting the PFX data. Call the method once for each PFX source that should be searched.The source remains configured across subsequent
LoadMimecalls and repeated decryptions. Chilkat continues searching after a PFX that does not contain the required recipient key.Not a signing-key fallback. Adding a PFX source does not make a public-only certificate usable by the signing methods. The signing certificate itself must have its private key, or the private key must be supplied explicitly by a method whose name ends in
Pk.- Parameters:
bd- thebdargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxSourceFile
Adds the PFX/P12 file at the local filesystem path inpfxFilePathto the internal collection of credential sources used by later S/MIME decryption operations.passwordis the password protecting the file. Call the method once for each PFX source that should be searched.The source remains configured across subsequent
LoadMimecalls and repeated decryptions. Chilkat continues searching after a PFX that does not contain the required recipient key.Not a signing-key fallback. Adding a PFX source does not make a public-only certificate usable by the signing methods. The signing certificate itself must have its private key, or the private key must be supplied explicitly by a method whose name ends in
Pk.- Parameters:
pfxFilePath- thepfxFilePathargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendPart
Appends a copy ofmimeas the last direct child. Chilkat does not retain a reference tomime, so later changes tomimedo not affect the appended part. The same source object may be appended more than once.If the current object is not multipart, it is converted to
multipart/mixed. The complete original entity, including its existing headers and body, becomes part 0; the copy ofmimebecomes part 1. The new outer entity contains its generated multipartContent-Type.Editing an appended child. Retrieve it with
. The object returned bypartAt(int, Mime)PartAtis a live child, unlike the copied input to this method.- Parameters:
mime- themimeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendPartFromFile
Reads the local file atfilename, creates an attachment part, and appends it. Filename-extension matching is case-insensitive.File kind Generated headers
.txttext/plain; charset=windows-1252; format=flowed,7bit, attachment filename and nameKnown binary type, such as
.PNGInferred media type such asimage/png,base64, attachment filename and nameUnknown extension
application/octet-stream,base64, attachment filename and nameIf the current object is not multipart, the same conversion described by
occurs. Calling this method on a new empty object therefore creates an empty part 0 and the file attachment as part 1.appendPart(Mime)- Parameters:
filename- thefilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
asnBodyToXml
Parses the current part's decoded body as ASN.1 DER and returns an XML representation of the ASN.1 structure. This is primarily useful for inspecting CMS/PKCS #7 bodies such asapplication/pkcs7-mimeorapplication/x-pkcs7-mime.Content-Type: application/pkcs7-mime; smime-type=signed-data Content-Transfer-Encoding: base64 MII...
Diagnostic conversion. The returned XML exposes ASN.1 tags, object identifiers, and values for inspection. It is not the MIME-to-XML representation returned by
.getXml()- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
clearEncryptCerts
public void clearEncryptCerts()Clears the internal recipient-certificate list populated by. A subsequent call toaddEncryptCert(Cert)requires certificates to be added again.encryptN() -
containsEncryptedParts
public boolean containsEncryptedParts()Returnstrueif the currently visible MIME tree contains a CMS/PKCS #7 encrypted entity. Bothapplication/pkcs7-mimeandapplication/x-pkcs7-mimeforms are recognized. Encrypted layers hide their contents. This method examines the MIME structure as it currently exists. It cannot report signed or encrypted entities inside ciphertext until the enclosing encrypted layer is successfully removed.- Returns:
- the result; this method never throws
ChilkatException
-
containsSignedParts
public boolean containsSignedParts()Returnstrueif the currently visible MIME tree contains a complete detached or opaque CMS/PKCS #7 signed entity. A standaloneapplication/pkcs7-signatureorapplication/x-pkcs7-signatureleaf part is not by itself classified as a signed message. Encrypted layers hide their contents. A signature nested inside encrypted data is not visible until the encrypted layer is removed. After a signature is successfully verified and unwrapped, this method returnsfalsebecause the signed wrapper no longer exists.- Returns:
- the result; this method never throws
ChilkatException
-
convert8Bit
public void convert8Bit()Recursively converts every part whoseContent-Transfer-Encodingis8bitorbinarytobase64. Both the child object'sEncodingproperty and the serialized header are updated. Parts using7bitor another encoding are unchanged. -
convertToMultipartAlt
public void convertToMultipartAlt()Wraps the current entity in a new outermultipart/alternativeentity. The original entity becomes the first and initially only child.The new outer entity retains message-level and custom headers such as
MIME-Version,Date,Subject,From,To,Content-ID,Content-Location, and custom fields. The originalContent-Type,Content-Transfer-Encoding,Content-Disposition, and body move to the first child. An existingcharsetparameter is retained on the new multipartContent-Type. Calling the method again wraps the existing multipart in another multipart layer; the operation is not idempotent.Alternative ordering. Additional representations can be appended with
. Conventionally, alternatives are ordered from least rich to most rich, such asappendPart(Mime)text/plainfollowed bytext/html.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
convertToMultipartMixed
public void convertToMultipartMixed()Wraps the current entity in a new outermultipart/mixedentity. The original entity becomes the first and initially only child.The new outer entity retains message-level and custom headers such as
MIME-Version,Date,Subject,From,To,Content-ID,Content-Location, and custom fields. The originalContent-Type,Content-Transfer-Encoding,Content-Disposition, and body move to the first child. An existingcharsetparameter is retained on the new multipartContent-Type. Calling the method again wraps the existing multipart in another multipart layer; the operation is not idempotent.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
convertToSigned
Creates an opaque (attached) S/MIME signature usingcert. The certificate itself must have access to its private key. On success, the current MIME entity is replaced by CMS/PKCS #7signed-datacontaining both the original MIME bytes and the signature.The result has no MIME child parts, uses Base64 content-transfer encoding, and has an
application/x-pkcs7-mimeorapplication/pkcs7-mimecontent type according to.getUseXPkcs7()and, for RSA keys,getSigningHashAlg()select the signing algorithms.getSigningAlg()This differs from
, which creates a visibleaddDetachedSignature(Cert)multipart/signedwrapper with a separate signature part.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
convertToSignedPk
Creates an opaque (attached) S/MIME signature usingcertas the signer certificate andprivateKeyas its associated private key. Use this method when the certificate and private key are supplied separately.The resulting CMS/PKCS #7
signed-datacontains the original MIME entity and its signature, has no MIME child parts, and uses Base64 content-transfer encoding. For a detachedmultipart/signedresult, use.addDetachedSignaturePk(Cert, PrivateKey)- Parameters:
cert- thecertargument (notnull)privateKey- theprivateKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decrypt
public void decrypt()Decrypts the current CMS/PKCS #7 encrypted MIME entity and replaces it with the recovered MIME content. Chilkat identifies the intended recipient from the CMS recipient information and searches configured credential sources for the matching certificate and private key.Source How it is supplied
Explicit certificate
oraddDecryptCert(Cert)decryptUsingCert(Cert)PFX/P12
,addPfxSourceFile(String, String), or aaddPfxSourceBd(BinData, String)DecryptUsingPfx...methodCertificate vault
useCertVault(XmlCertVault)Platform certificate store Windows certificate stores and the macOS Keychain are searched automatically where supported
On success,
andgetNumDecryptCerts()identify the certificate used, andlastDecryptCert(int, Cert)reports the content-encryption algorithm and key size. On failure, the encrypted MIME remains unchanged.getLastJsonData(JsonObject)Serialization after decryption. The recovered MIME content is restored semantically, but its generated serialization is not guaranteed to be byte-for-byte identical to the bytes that existed before encryption.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decrypt2
Decrypts the current CMS/PKCS #7 encrypted MIME entity using the certificate incertand its associated private key inprivateKey. On success, the encrypted wrapper is replaced by the recovered MIME content, the decryption certificate is available through, and operation details are available throughlastDecryptCert(int, Cert). On failure, the encrypted MIME remains unchanged.getLastJsonData(JsonObject)Use this method when the certificate and private key are stored separately. Use
when Chilkat should locate the credential from configured sources.decrypt()- Parameters:
cert- thecertargument (notnull)privateKey- theprivateKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decryptUsingCert
Decrypts the current CMS/PKCS #7 encrypted MIME entity usingcert. The certificate must have access to its corresponding private key; a public-only certificate is insufficient. On success, the encrypted wrapper is replaced by the recovered MIME content andcertis recorded in the decryption results. On failure, the encrypted MIME remains unchanged.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decryptUsingPfxFile
Decrypts the current CMS/PKCS #7 encrypted MIME entity using certificates and private keys from the PFX/P12 file at the local filesystem path inpfxFilePath.pfxPasswordis the password protecting the file.On success, the encrypted wrapper is replaced by the recovered MIME content and the matching certificate is available through
.lastDecryptCert(int, Cert)may include both CMS decryption details and information produced while reading the PFX. On failure, the encrypted MIME remains unchanged.getLastJsonData(JsonObject)- Parameters:
pfxFilePath- thepfxFilePathargument (notnull)pfxPassword- thepfxPasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encrypt
Encrypts the current MIME entity for the recipient certificate incertand replaces it with CMS/PKCS #7 encrypted S/MIME.certmust be RSA-based. Only the recipient's public key is needed to encrypt; the matching private key is required later to decrypt.The default content encryption is AES-128-CBC.
andgetPkcs7CryptAlg()select the symmetric algorithm and key length. By default, RSAES-PKCS1-v1_5 transports the content-encryption key; setgetPkcs7KeyLength()togetOaepPadding()trueto use RSAES-OAEP, withandgetOaepHash()controlling its parameters.getOaepMgfHash()The generated MIME uses Base64 transfer encoding, the filename
smime.p7m, and anapplication/x-pkcs7-mimeorapplication/pkcs7-mimecontent type according to. After encryption,getUseXPkcs7()can report the recipient identifiers stored in the CMS data. If encryption fails, the original MIME remains unchanged.getDecryptCertInfo(JsonObject)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encryptN
public void encryptN()Encrypts the current MIME entity for every certificate previously added with. Each recipient receives independently protected access to the same encrypted content.addEncryptCert(Cert)Add one certificate per intended recipient, call this method, and use
before preparing a different recipient set.clearEncryptCerts()- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getBodyBd
Replaces the contents ofbinDatwith the decoded body bytes of the current part. Existing bytes inbinDatare discarded. Base64 and quoted-printable are decoded. MIME headers, multipart boundaries, and child parts are not included.- Parameters:
binDat- thebinDatargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getBodyDecoded
Returns the decoded body as text. Chilkat first decodes theContent-Transfer-Encodingand then interprets text according to the declared charset. Use a byte-oriented getter for binary content. A string result cannot reliably represent arbitrary binary bytes or embedded NUL bytes. UseorgetBodyBd(BinData)for binary payloads.GetBodyBinary- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getBodyEncoded
Returns the current part's transfer-encoded body text without decoding Base64 or quoted-printable. The returned value is Chilkat's normalized serialization of the body, not necessarily the exact text that appeared in the loaded MIME. For example, Base64 padding and line wrapping or quoted-printable spelling may be regenerated.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getDecryptCertInfo
Examines the current encrypted S/MIME entity and writes recipient-certificate identifiers to theJsonObjectincertInfo. This can be used to identify which certificate and private key must be made available before callingordecrypt(). A typical result is:unwrapSecurity(){ "recipientInfo": [ { "serial": "166FC256FC66A64B20C710F15BFAB63E", "issuerCN": "Example Issuing CA" } ] }The method returns
falseand writes an empty JSON object when the current MIME entity is not encrypted, including after it has already been decrypted.No private key is revealed. The encrypted message contains recipient identifiers and encrypted key material, not recipient private keys.
- Parameters:
certInfo- thecertInfoargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getEntireBody
Returns the complete serialized body of the current MIME entity. For multipart MIME, this includes boundary delimiters, each child part's headers and body, and the closing boundary. The current entity's own header fields are not included.Use
when the decoded payload of a single part is needed.getBodyDecoded()- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getEntireHead
Returns the complete serialized header section of the current MIME entity. The body and any multipart child content are not included.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getHeaderField
Returns the value of the first header field whose name matchesfieldNamecase-insensitively. Duplicate later occurrences are not combined. Returns null when no matching field exists.- Parameters:
fieldName- thefieldNameargument (notnull)- Returns:
- the result, or
nullif not found (no exception is thrown in that case)
-
getHeaderFieldAttribute
Returns an attribute value parsed from the first header field named byname. Both the header name andattrNameattribute name are matched case-insensitively. Surrounding quotation marks are removed, and semicolons inside a quoted value are handled as part of the value.Extended parameters such as
filename*=utf-8''r%C3%A9sum%C3%A9.txtare returned in their raw encoded form; this method does not percent-decode or apply the declared charset. Returns null when the field or attribute is absent.- Parameters:
name- thenameargument (notnull)attrName- theattrNameargument (notnull)- Returns:
- the result, or
nullif not found (no exception is thrown in that case)
-
getHeaderFieldName
Returns the name of the header-field occurrence at zero-basedindex. Header order and original casing are preserved for ordinary loaded headers. Useto determine the valid range.getNumHeaderFields()- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getHeaderFieldValue
Returns the unfolded value of the header-field occurrence at zero-basedindex. Continuation lines are combined into a single value. Useto determine the valid range.getNumHeaderFields()- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getLastJsonData
Copies structured details from the most recent operation intojsonwhen such details are available. Many methods do not produce JSON data.Operation Typical result
Signing or encryption An empty JSON object.
verify()pkcs7.verifydetails such as embedded certificates, digest algorithms, signer information, signature algorithm, signing time, message digest, and authenticated attributes.Decryption
pkcs7.decryptdetails including the content algorithm and key size. A PFX-based method may also include PKCS #12 parsing details.May contain both verification and decryption sections when both kinds of security layer were removed.unwrapSecurity()Read immediately. The information describes the most recent applicable call on this object and can be replaced by a later operation.
- Parameters:
json- thejsonargument (notnull)
-
getMime
Serializes and returns the complete MIME entity, including headers, body, multipart boundaries, and all descendants. Serialization is normalized. The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getMimeBd
Serializes the complete MIME entity and appends its bytes tobindat. ExistingBinDatabytes are preserved. Use this method when arbitrary binary body bytes must not pass through a text string. Serialization is normalized. The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten.- Parameters:
bindat- thebindatargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getMimeSb
Serializes the complete MIME entity and appends it tosb. ExistingStringBuildercontent is preserved. Serialization is normalized. The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten.- Parameters:
sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getSignatureSigningTimeStr
Returns the CMSsigningTimesigned attribute for the signer at zero-basedindex, formatted as an RFC 822-style date string in GMT. For example:Wed, 29 Jul 2026 14:32:58 GMT
Call
first because the attribute is optional. UsehasSignatureSigningTime(int)for the signer count.getNumSignerCerts()Signing time is not a trusted timestamp. The CMS
signingTimevalue is supplied by the signer. It is different from a timestamp token issued and signed by a trusted timestamp authority.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getStructure
Returns a concise MIME-tree summary.fmtis case-insensitive. The valuexmlselects XML output; all other values, includingtext, an empty string, or an unrecognized value, select the indented text format.multipart/mixed text/plain application/octet-stream<multipart-mixed> <text-plain /> <application-octet-stream /> </multipart-mixed>- Parameters:
fmt- thefmtargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getXml
Converts the MIME tree to Chilkat's XML representation and returns it as a string. Header names become XML element names, structured header parameters become XML attributes, duplicate headers become repeated elements, multipart children are nested insubpartelements, and binary bodies are represented in an encoded textual form. XML round-tripping is semantic. Loading this XML reconstructs an equivalent MIME tree, but it is not byte-preserving and header names are normalized to lowercase.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hasSignatureSigningTime
public boolean hasSignatureSigningTime(int index)Returnstrueif the signer at zero-basedindexhas a CMSsigningTimesigned attribute. Usefor the signer count andgetNumSignerCerts()to retrieve the value.getSignatureSigningTimeStr(int)- Parameters:
index- theindexargument- Returns:
- the result; this method never throws
ChilkatException
-
isApplicationData
public boolean isApplicationData()Returnstruewhenbegins withgetContentType()application/. It returnsfalsefor an empty or malformed media type.- Returns:
- the result; this method never throws
ChilkatException
-
isAttachment
public boolean isAttachment()Returnstruewhen the current part's disposition value isattachment, matched case-insensitively. Parameters such asfilenamedo not affect the test. Aninlinepart remains non-attachment even when it has a filename.- Returns:
- the result; this method never throws
ChilkatException
-
isAudio
public boolean isAudio()- Returns:
- the result; this method never throws
ChilkatException
-
isEncrypted
public boolean isEncrypted()Returnstruewhen the current MIME entity is a CMS/PKCS #7 encrypted S/MIME wrapper. Bothapplication/pkcs7-mimeandapplication/x-pkcs7-mimeforms are recognized. To search the visible MIME tree rather than only the current entity, use.containsEncryptedParts()- Returns:
- the result; this method never throws
ChilkatException
-
isHtml
public boolean isHtml()ReturnstruewhenisgetContentType()text/html. TheContentTypeproperty must contain only the media type; set parameters such ascharsetseparately.- Returns:
- the result; this method never throws
ChilkatException
-
isImage
public boolean isImage()- Returns:
- the result; this method never throws
ChilkatException
-
isMultipart
public boolean isMultipart()- Returns:
- the result; this method never throws
ChilkatException
-
isMultipartAlternative
public boolean isMultipartAlternative()- Returns:
- the result; this method never throws
ChilkatException
-
isMultipartMixed
public boolean isMultipartMixed()- Returns:
- the result; this method never throws
ChilkatException
-
isMultipartRelated
public boolean isMultipartRelated()- Returns:
- the result; this method never throws
ChilkatException
-
isPlainText
public boolean isPlainText()- Returns:
- the result; this method never throws
ChilkatException
-
isSigned
public boolean isSigned()Returnstruewhen the current MIME entity is a complete CMS/PKCS #7 signed S/MIME wrapper, including detachedmultipart/signedand opaque signed-data forms. A standaloneapplication/pkcs7-signatureorapplication/x-pkcs7-signatureleaf part is not by itself classified as a signed message. To search the visible MIME tree, use.containsSignedParts()- Returns:
- the result; this method never throws
ChilkatException
-
isText
public boolean isText()- Returns:
- the result; this method never throws
ChilkatException
-
isVideo
public boolean isVideo()- Returns:
- the result; this method never throws
ChilkatException
-
isXml
public boolean isXml()Returnstrueonly fortext/xmlorapplication/xml. It does not classify structured-suffix media types such asapplication/soap+xml,application/atom+xml, orimage/svg+xmlas XML.- Returns:
- the result; this method never throws
ChilkatException
-
lastDecryptCert
Loads intocertthe decryption certificate at zero-basedindexfrom the most recent successful decryption or security-unwrapping operation. Valid indexes range from0throughgetNumDecryptCerts()- 1. The returned certificate has access to the private key used for decryption.An invalid index returns
falseand leavescertunchanged.- Parameters:
index- theindexargumentcert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
lastSignerCert
Loads intocertthe signer certificate at zero-basedindexfrom the most recent successful signature-verification or security-unwrapping operation. Valid indexes range from0throughgetNumSignerCerts()- 1. The returned certificate normally contains only the public key; it does not gain access to the signer's private key.An invalid index returns
falseand leavescertunchanged. A later failed call toclears the signer results.verify()- Parameters:
index- theindexargumentcert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadMime
Parses the complete MIME text inmimeMsgand replaces the current object's headers, body, and multipart tree. A successful call always replaces the previous MIME.If no blank line separates headers from the body, lines that appear header-like are parsed as headers and the body is empty. Data after the header/body separator belongs to the body.
Permissive parser and normalized output. Chilkat accepts many imperfect messages. Observed behavior includes ignoring malformed header lines and leading non-header text, using the last duplicate
Content-Type, repairing a missing multipart closing delimiter during serialization, treating unmatched boundary-like text as an ordinary body, and tolerating malformed Base64 or quoted-printable. LF-only and CR-only input are accepted; generated headers and multipart framing use CRLF. Loading and reserializing is therefore not guaranteed to reproduce the original bytes, and multipart preamble and epilogue text are not retained. Text input is not a raw-byte container. UseorloadMimeBd(BinData)for arbitrary 8-bit bytes or embedded NUL bytes.LoadMimeBytes- Parameters:
mimeMsg- themimeMsgargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadMimeBd
Parses complete MIME bytes frombindatand replaces the current MIME on success. This is the preferred loader when the MIME can contain arbitrary 8-bit body bytes or embedded NUL bytes. Parsing tolerance and serialization normalization are the same as.loadMime(String)- Parameters:
bindat- thebindatargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadMimeFile
Reads and parses the complete MIME entity from the local file atfileName. A successful call replaces the current MIME. If the file cannot be opened, the method returnsfalseand preserves the existing object unchanged.Parsing tolerance and serialization normalization are the same as
.loadMime(String)- Parameters:
fileName- thefileNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadMimeSb
Parses complete MIME text fromsband replaces the current MIME on success. Parsing tolerance and serialization normalization are the same as. Use byte input for arbitrary MIME bytes. AloadMime(String)StringBuilderis text-oriented. Usefor binary MIME containing arbitrary 8-bit values or NUL bytes.loadMimeBd(BinData)- Parameters:
sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXml
Reconstructs a MIME tree from Chilkat's MIME XML inxml. On success, the current object is replaced. If the XML is invalid, the method returnsfalseand preserves the existing MIME unchanged.The reconstructed MIME is semantically equivalent but not byte-identical to the MIME that produced the XML. Header names are normalized to lowercase.
- Parameters:
xml- thexmlargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXmlFile
Reads Chilkat MIME XML from the local file atfileNameand reconstructs the MIME tree. On success, the current object is replaced. If the file cannot be opened or the XML is invalid, the method returnsfalseand preserves the existing MIME unchanged. Header names are normalized to lowercase during reconstruction.- Parameters:
fileName- thefileNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newMessageRfc822
Clears the current object and initializes it asmessage/rfc822. Its body is a serialized copy ofmimeObjectat the time of the call. Later modifications tomimeObjectdo not change the embedded message.- Parameters:
mimeObject- themimeObjectargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newMultipartAlternative
public void newMultipartAlternative()Initializes an emptymultipart/alternativeentity. Clears all existing headers, body content, and child parts. The new object contains only a multipartContent-Typewith an automatically generated boundary, has zero parts, and does not automatically addMIME-Version.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newMultipartMixed
public void newMultipartMixed()Initializes an emptymultipart/mixedentity. Clears all existing headers, body content, and child parts. The new object contains only a multipartContent-Typewith an automatically generated boundary, has zero parts, and does not automatically addMIME-Version.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newMultipartRelated
public void newMultipartRelated()Initializes an emptymultipart/relatedentity. Clears all existing headers, body content, and child parts. The new object contains only a multipartContent-Typewith an automatically generated boundary, has zero parts, and does not automatically addMIME-Version.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
partAt
Provides live access to the direct child at zero-basedindexthroughsubPart. ModifyingsubPartafter a successful call modifies the child stored in the parent MIME tree.Valid indexes range from
0throughgetNumParts()- 1. An invalid index returnsfalseand preservessubPartunchanged.Different from AppendPart.
stores a copy of its argument. This method exposes the actual stored child.appendPart(Mime)- Parameters:
index- theindexargumentsubPart- thesubPartargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
partsToFiles
Recursively traverses the MIME tree and saves each part having a nonemptyfilenameparameter to the existing directory inpath. Anameparameter alone is not used as a fallback. The disposition may beattachmentorinline; a filename is what controls extraction.- Only the final path component of a MIME filename is used. Directory components, absolute paths,
and
..traversal are discarded. - On Windows, invalid filename characters are replaced with underscores.
- Duplicate filenames target the same path; later parts overwrite earlier parts.
stis appended to rather than cleared. Each added entry is the full path actually written, including any sanitized filename.- The destination directory is not created. If it does not exist, the method returns
false, creates no files, and appends nothing tost.
Treat MIME filenames as untrusted. Use a controlled destination directory and apply any application-specific policy for file types, size limits, overwriting, and renaming.
- Parameters:
path- thepathargument (notnull)st- thestargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Only the final path component of a MIME filename is used. Directory components, absolute paths,
and
-
removeHeaderField
Removes fields whose name matchesfieldNamecase-insensitively. IfbAllOccurrencesisfalse, only the first matching occurrence is removed. IfbAllOccurrencesistrue, all matching occurrences are removed. Remaining fields retain their relative order.- Parameters:
fieldName- thefieldNameargument (notnull)bAllOccurrences- thebAllOccurrencesargument
-
removePart
public void removePart(int index)Removes the direct child at zero-basedindex. Valid indexes range from0throughgetNumParts()- 1. An out-of-range index returnsfalseand leaves the tree unchanged.- Parameters:
index- theindexargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveBody
Writes the decoded body bytes of the current part to the local path infilename. Base64 and quoted-printable are decoded. MIME headers and multipart framing are not written. File behavior. Existing files are overwritten. Parent directories are not created, and passing a directory as the destination fails. On Windows, an existing read-only file is replaced and the read-only attribute is removed.- Parameters:
filename- thefilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveMime
Serializes the complete MIME entity and writes it to the local path infilename, including headers, body, multipart boundaries, and all descendants. Serialization is normalized. The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten. File behavior. Existing files are overwritten. Parent directories are not created, and passing a directory as the destination fails. On Windows, an existing read-only file is replaced and the read-only attribute is removed.- Parameters:
filename- thefilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveXml
Writes Chilkat's MIME XML representation to the local path infilename. The file can be loaded by. File behavior. Existing files are overwritten. Parent directories are not created, and passing a directory as the destination fails. On Windows, an existing read-only file is replaced and the read-only attribute is removed.loadXmlFile(String)- Parameters:
filename- thefilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBody
Sets the current part's body fromstrwhile preserving existing content headers such asContent-Type,charset, andContent-Transfer-Encoding. Multipart entities serialize their child parts. Calling this method on a multipart object changes what the body getter methods return, but the assigned body is not included in the serialized multipart output while child parts are present. Build multipart content throughandappendPart(Mime).partAt(int, Mime)- Parameters:
str- thestrargument (notnull)
-
setBodyBd
Sets the decoded body bytes frombd, changesContent-Transfer-Encodingtobase64, and preserves the bytes exactly. It does not set aContent-Type, disposition, filename, or name; set those separately when needed.- Parameters:
bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBodyFromEncoded
Sets the body from transfer-encoded text.encodingmust bebase64orquoted-printable; other values, including7bit,8bit,binary, an unknown name, or an empty string, cause failure.Base64 whitespace is accepted and the stored representation is normalized. Invalid Base64 causes the method to return
false. On any failure, all existing headers and body content are preserved unchanged.Do not encode twice.
strmust already be in the encoding named byencoding. To provide decoded bytes, useorsetBodyBd(BinData).SetBodyFromBinary- Parameters:
encoding- theencodingargument (notnull)str- thestrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBodyFromFile
Reads the local file atfileNameand replaces the current part's body and content headers according to the filename extension.File kind Result
.txttext/plain; charset=windows-1252; format=flowed,7bit.htmltext/html; charset=windows-1252,7bitUnknown extension
application/octet-stream,base64,attachment, and filename/name parameters based on the local filenameIf the file cannot be opened, the method returns
falseand preserves the existing MIME unchanged.- Parameters:
fileName- thefileNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBodyFromHtml
Setsstras HTML and changes the media type totext/html. For ASCII input, Chilkat usesContent-Transfer-Encoding: 7bitand does not add a charset. Existing unrelated headers are preserved.- Parameters:
str- thestrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBodyFromPlainText
Setsstras plain text. For ASCII input, Chilkat setsContent-Type: text/plain; format=flowedandContent-Transfer-Encoding: 7bitwithout a charset. For non-ASCII UTF-8 input, it setscharset=utf-8and uses8bit. Existing unrelated headers are preserved.- Parameters:
str- thestrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBodyFromXml
Setsstras XML, changes the media type totext/xml, and selects a transfer encoding appropriate for the text. For ASCII input, Chilkat uses7bitand does not add a charset.The XML declaration's
encodingvalue is not copied to the MIMEcharsetparameter.Different from LoadXml. This method places an XML document in the MIME body.
reconstructs an entire MIME object from Chilkat MIME XML.loadXml(String)- Parameters:
str- thestrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setHeaderField
Sets one header field named byname. Matching is case-insensitive. All existing occurrences are removed and one replacement is inserted. If no field exists, a new one is added. Passing an emptyvalueremoves all matching occurrences rather than creating an empty-valued field.Use
to append another occurrence or to create an empty-valued field.addHeaderField(String, String)- Parameters:
name- thenameargument (notnull)value- thevalueargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setVerifyCert
Suppliescertas a signer-certificate fallback for subsequent signature verification. This is useful when the CMS/PKCS #7 signature does not embed the signer certificate and Chilkat cannot otherwise locate it. Only the public key is required. This does not require a particular signer. An embedded signer certificate takes precedence. If the CMS signature embeds the correct signer certificate, verification can succeed even whencertis an unrelated certificate, andreturns the embedded certificate. To enforce signer identity, verify first and then compare the returned signer certificate using application-defined criteria such as its serial number, fingerprint, subject, issuer, or trusted chain.lastSignerCert(int, Cert)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
unwrapSecurity
public void unwrapSecurity()Removes supported S/MIME security layers and restores the underlying MIME content. It handles both common layer orders: a message signed and then encrypted, and a message encrypted and then signed. It continues through nested top-level layers until no additional supported security wrapper remains.After a successful call,
andgetNumSignerCerts()identify verified signers, whilelastSignerCert(int, Cert)andgetNumDecryptCerts()identify decryption certificates.lastDecryptCert(int, Cert)may contain bothgetLastJsonData(JsonObject)pkcs7.verifyandpkcs7.decryptdetails.Additional result headers. When
isgetUnwrapExtras()true, Chilkat adds headers such asX-NumPartsSigned,X-SignaturesValid,X-NumPartsEncrypted, andX-Decrypted. Set it tofalseto omit these headers.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
urlEncodeBody
Replaces the current body with anapplication/x-www-form-urlencoded-style representation using the character set named bycharset. Spaces become+, a literal plus becomes%2B, non-ASCII bytes become%HHsequences, and separators such as&and=remain unchanged.Input: a b+c&d=e Output: a+b%2Bc&d=e
The MIME content headers are not changed. If the named character set is unsupported, the body remains unchanged.
Not a MIME transfer encoding. This operation is distinct from
base64andquoted-printable.- Parameters:
charset- thecharsetargument (notnull)
-
useCertVault
Setsvaultas the certificate vault used to locate certificates and private keys for S/MIME encryption, decryption, signing, and verification. Only one vault is active; each call replaces the previously configured vault.Use
XmlCertVaultwhen credentials are maintained independently of platform certificate stores or individual PFX sources.- Parameters:
vault- thevaultargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
verify
public void verify()Verifies the current CMS/PKCS #7 signed MIME entity and removes the signature wrapper. Both detachedmultipart/signedmessages and opaque CMSsigned-dataare supported. The method works with signed MIME loaded from serialized input as well as MIME signed by the current object.On success, the object is restored to the MIME structure and content that was signed,
reports the verified signer count,getNumSignerCerts()returns the signer certificate, andlastSignerCert(int, Cert)reports CMS verification details. A detached signature can restore the original serialization exactly, but opaque signed-data restoration is semantic and is not guaranteed to reproduce byte-for-byte identical MIME serialization.getLastJsonData(JsonObject)On failure, the signed wrapper remains unchanged, no content is unwrapped, and the signer-result count is cleared to
0.SetVerifyCert is a fallback, not a signer restriction. When the CMS data embeds a usable signer certificate, Chilkat uses that embedded certificate. Verification can therefore succeed even when
was given an unrelated certificate. Enforce signer identity after verification by examiningsetVerifyCert(Cert). What verification proves. Cryptographic verification establishes that the signed bytes have not changed and that the signature matches the signer certificate. Application trust decisions may additionally require validating the certificate chain, identity, usage, validity period, and revocation status.lastSignerCert(int, Cert)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-