ICertificates.Add

Syntax

Add(Id: String): ICertificate;

Parameters

Id. Identifier which will be assigned to the certificate.

Description

The Add method adds certificate to the collection and returns its parameters.

Example

To execute the example, add a security certificate to the file C:\Certificates\sp.pem.

Add links to the Metabase and IO system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Certs: ICertificates;
    Cert: ICertificate;
    FStream: IFileStream;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Check out license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    Certs := MS.Policy.Certificates;
    
// Add a certificate
    Cert := Certs.Add("sp");
    
// Load certificate from file
    FStream := New FileStream.Create("C:\Certificates\sp.pem", FileOpenMode.Read, FileShare.DenyNone);
    Cert.SetData(FStream);
    
// Save changes
    MS.Apply;
    
// Check in license
    Lic := Null;
End Sub UserProc;

After executing the example, security certificate will be added to the repository base. Certificate contents will be loaded from the specified file.

See also:

ICertificates