CertificateHolder.Create

CertificateHolder Create method. Creates CertificateHolder object using byte array of PKCS12 store and its password.

Create(byte[], SecureString)

Creates CertificateHolder object using byte array of PKCS12 store and its password.

public static CertificateHolder Create(byte[] certBytes, SecureString password)
ParameterTypeDescription
certBytesByte[]A byte array that contains data from an X.509 certificate.
passwordSecureStringThe password required to access the X.509 certificate data.

Return Value

An instance of CertificateHolder

Exceptions

exceptioncondition
ArgumentNullExceptionThrown if certBytes is null
ArgumentNullExceptionThrown if password is null
SecurityExceptionThrown if PKCS12 store contains no aliases
IOExceptionThrown if there is wrong password or corrupted file.

See Also


Create(byte[], string)

Creates CertificateHolder object using byte array of PKCS12 store and its password.

public static CertificateHolder Create(byte[] certBytes, string password)
ParameterTypeDescription
certBytesByte[]A byte array that contains data from an X.509 certificate.
passwordStringThe password required to access the X.509 certificate data.

Return Value

An instance of CertificateHolder

Exceptions

exceptioncondition
ArgumentNullExceptionThrown if certBytes is null
ArgumentNullExceptionThrown if password is null
SecurityExceptionThrown if PKCS12 store contains no aliases
IOExceptionThrown if there is wrong password or corrupted file.

See Also


Create(string, string)

Creates CertificateHolder object using path to PKCS12 store and its password.

public static CertificateHolder Create(string fileName, string password)
ParameterTypeDescription
fileNameStringThe name of a certificate file.
passwordStringThe password required to access the X.509 certificate data.

Return Value

An instance of CertificateHolder

Exceptions

exceptioncondition
ArgumentNullExceptionThrown if fileName is null
ArgumentNullExceptionThrown if password is null
SecurityExceptionThrown if PKCS12 store contains no aliases
IOExceptionThrown if there is wrong password or corrupted file.

Examples

Demonstrates how to sign document.

CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");

SignOptions signOptions = new SignOptions();
signOptions.Comments = "Test Signing";
signOptions.SignTime = DateTime.Now;

Signer.Sign(MyDir + "Simple.docx", ArtifactsDir + "Signed.docx", certHolder, signOptions);

See Also


Create(string, string, string)

Creates CertificateHolder object using path to PKCS12 store, its password and the alias by using which private key and certificate will be found.

public static CertificateHolder Create(string fileName, string password, string alias)
ParameterTypeDescription
fileNameStringThe name of a certificate file.
passwordStringThe password required to access the X.509 certificate data.
aliasStringThe associated alias for a certificate and its private key

Return Value

An instance of CertificateHolder

Exceptions

exceptioncondition
ArgumentNullExceptionThrown if fileName is null
ArgumentNullExceptionThrown if password is null
SecurityExceptionThrown if PKCS12 store contains no aliases
IOExceptionThrown if there is wrong password or corrupted file.
SecurityExceptionThrown if there is no private key with the given alias

See Also