Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get Certificate Policy
See more Certificates Examples
Demonstrates how to get a certificate's policy OIDs (if any)Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Cert,
Chilkat.Xml;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
cert: TCert;
oid: string;
strXml: string;
xml: TXml;
begin
success := False;
cert := TCert.Create;
success := cert.LoadFromFile('qa_data/certs/sample.cer');
if (success = False) then
begin
WriteLn(cert.LastErrorText);
Exit;
end;
// The certificatePolicies OID is 2.5.29.32
oid := '2.5.29.32';
strXml := cert.GetExtensionAsXml(oid);
if (cert.LastMethodSuccess = True) then
begin
WriteLn(strXml);
// Sample result:
// <sequence><sequence><oid>2.16.840.1.101.2.1.11.39</oid></sequence></sequence>
xml := TXml.Create;
xml.LoadXml(strXml);
WriteLn('Policy OID = ' + xml.GetChildContent('sequence|oid'));
end;
cert.Free;
xml.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.