ICertificates.Add

Fore Syntax

Add(Id: String): ICertificate;

Fore.NET Syntax

Add(Id: String): Prognoz.Platform.Interop.Metabase.ICertificate;

Parameters

Id. Identifier which will be assigned to the certificate.

Description

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

Fore Example

Executing the example requires the file named sp.pem where security certificate is stored.

Sub UserProc;
Var
    MB: IMetabase;
    MSecurity: IMetabaseSecurity;
    Certs: ICertificates;
    Cert: ICertificate;
    FStream: IFileStream;
Begin
    MB := MetabaseClass.Active;
    MSecurity := MB.Security;
    Certs := MSecurity.Policy.Certificates;
    //Add a certificate
    Cert := Certs.Add("sp");
    //Load certificate contents from the file
    FStream := New FileStream.Create("D:\Work\Certificates\sp.pem", FileOpenMode.Read, FileShare.DenyNone);
    Cert.SetData(FStream);
    //Apply changes
    MSecurity.Apply;
End Sub UserProc;

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

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports System.IO;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MSecurity: IMetabaseSecurity;
    Certs: ICertificates;
    Cert: ICertificate;
    FStream: FileStream;
Begin
    MB := Params.Metabase;
    MSecurity := MB.Security;
    Certs := MSecurity.Policy.Certificates;
    //Add a certificate
    Cert := Certs.Add("sp");
    //Load certificate contents from the file
    FStream := New FileStream("D:\Work\Certificates\sp.pem", FileMode.Open, FileAccess.Read);
    Cert.SetData(FStream);
    //Apply changes
    MSecurity.Apply();
End Sub;

See also:

ICertificates