Class XmlCertVault
- All Implemented Interfaces:
AutoCloseable
Collect certificates, certificate chains, PEM data, and PFX private keys in an XML vault.
Chilkat.XmlCertVault stores certificates and private-key
material in a portable XML-based certificate vault. It can add individual
certificates, certificate chains, DER or encoded certificates, PEM files,
certificate strings, and PFX/PKCS12 data from files, memory, encoded text, or
existing Chilkat objects. The vault can then be exported as XML, loaded from
XML, or saved to an XML file for later reuse by other Chilkat certificate and
TLS workflows.
Add certificates
Add certificates from Cert objects, files, PEM strings,
binary DER bytes, or encoded data such as Base64 or hex.
Add certificate chains
Import an entire CertChain when related issuer and
intermediate certificates should be kept together in the vault.
Add PEM content
Load PEM files containing one or more certificates and/or private keys, including encrypted PEM content when a password is supplied.
Add PFX / PKCS12
Add PFX data from a Pfx object, file, byte array, or encoded
string, using the PFX password to import private-key material.
Master password protection
Use MasterPassword to protect access to private keys stored
in the vault.
Load and save XML
Export the vault with GetXml, load it with
LoadXml or LoadXmlFile, and persist it with
SaveXml.
Common pattern:
Create an XmlCertVault, set MasterPassword when the
vault will contain private keys, add certificates or PFX/PEM material, then
save the vault with SaveXml or keep the XML string from
GetXml. Later, reload the same vault with LoadXml
or LoadXmlFile and provide the same master password before using
private keys.
Security note:
Certificates are stored unencrypted, but private keys are stored using
256-bit AES encryption. The individual PFX passwords are also stored
encrypted with the vault's MasterPassword, which is required to
access any private keys contained in the XML vault.
</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 TypeMethodDescriptionvoidAdds a certificate to the XML vault.voidaddCertChain(CertChain certChain)Adds a chain of certificates to the XML vault.voidaddCertEncoded(String encodedBytes, String encoding)Adds a certificate to the XML vault where certificate is passed directly from encoded bytes (such as Base64, Hex, etc.).voidaddCertFile(String path)Adds a certificate to the XML vault.voidaddCertString(String certData)Adds a certificate from any string representation format such as PEM.voidaddPemFile(String path, String password)Adds the contents of a PEM file to the XML vault.voidAdds a PFX (PKCS12) to the XML vault.voidaddPfxEncoded(String encodedBytes, String encoding, String password)Adds a PFX to the XML vault where PFX is passed directly from encoded bytes (such as Base64, Hex, etc.).voidaddPfxFile(String path, String password)Adds a PFX file to the XML vault.The master password for the vault.getXml()Returns the contents of the cert vault as an XML string.voidLoads from an XML string.voidloadXmlFile(String path)Loads from an XML file.voidSaves the contents to an XML file.voidsetMasterPassword(String value)Sets theMasterPasswordproperty; seegetMasterPassword().Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
XmlCertVault
public XmlCertVault()Creates a newXmlCertVaultobject.
-
-
Method Details
-
getMasterPassword
The master password for the vault. Certificates are stored unencrypted, but private keys are stored 256-bit AES encrypted using the individual PFX passwords. The PFX passwords are stored 256-bit AES encrypted using the master password. The master password is required to acces any of the private keys stored within the XML vault.- Returns:
- the value of the
MasterPasswordproperty
-
setMasterPassword
Sets theMasterPasswordproperty; seegetMasterPassword().- Parameters:
value- the new value (notnull)
-
addCert
Adds a certificate to the XML vault.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addCertChain
Adds a chain of certificates to the XML vault.- Parameters:
certChain- thecertChainargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addCertEncoded
Adds a certificate to the XML vault where certificate is passed directly from encoded bytes (such as Base64, Hex, etc.). The encoding is indicated byencoding.- Parameters:
encodedBytes- theencodedBytesargument (notnull)encoding- theencodingargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addCertFile
Adds a certificate to the XML vault.- Parameters:
path- thepathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addCertString
Adds a certificate from any string representation format such as PEM.- Parameters:
certData- thecertDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPemFile
Adds the contents of a PEM file to the XML vault. The PEM file may be encrypted, and it may contain one or more certificates and/or private keys. The password is optional and only required if the PEM file contains encrypted content that requires a password.- Parameters:
path- thepathargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfx
Adds a PFX (PKCS12) to the XML vault.- Parameters:
pfx- thepfxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxEncoded
Adds a PFX to the XML vault where PFX is passed directly from encoded bytes (such as Base64, Hex, etc.). The encoding is indicated byencoding.- Parameters:
encodedBytes- theencodedBytesargument (notnull)encoding- theencodingargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxFile
Adds a PFX file to the XML vault.- Parameters:
path- thepathargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getXml
Returns the contents of the cert vault as an XML string.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXml
Loads from an XML string.- Parameters:
xml- thexmlargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXmlFile
Loads from an XML file.- Parameters:
path- thepathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveXml
Saves the contents to an XML file.- Parameters:
path- thepathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-