CertificateStoreAddCertificate Method |
Adds the specified certificate to the store.
Namespace: MailBee.SecurityAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool AddCertificate(
Certificate cert,
bool overwrite
)
Public Function AddCertificate (
cert As Certificate,
overwrite As Boolean
) As Boolean
Parameters
- cert
- Type: MailBee.SecurityCertificate
The certificate that should be added. - overwrite
- Type: SystemBoolean
Sets whether the same certificate (if it already exists in the store) should be overwritten or not. Ignored in .NET Standard 2.0 edition.
Return Value
Type:
Booleantrue if certificate was successfully added to the store; otherwise,
false.
Exceptions Remarks Starting from .NET Standard 2.0 edition, this method is just a wrapper around
Add(X509Certificate2) method.
Examples This sample registers a new certificate store, reads a certificate from a file and adds this certificate to the newly created store.
using MailBee.Security;
CertificateStore.RegisterSystemStore(@"TestStore", RegistryStoreLocation.CurrentUser);
CertificateStore store = new CertificateStore(@"TestStore", CertStoreType.System, null);
Certificate cert = new Certificate(@"C:\Temp\test.cer", CertFileType.Cer, null);
store.AddCertificate(cert, true);
Imports MailBee.Security
CertificateStore.RegisterSystemStore("TestStore", RegistryStoreLocation.CurrentUser)
Dim store As CertificateStore = New CertificateStore("TestStore", CertStoreType.System, Nothing)
Dim cert As Certificate = New Certificate("C:\Temp\test.cer", CertFileType.Cer, Nothing)
store.AddCertificate(cert, True)
See Also