CertificateInfo Property

Applies to TestComplete 14.74, last modified on March 31, 2021

Description

Use the CertificateInfo property to obtain information about the authentication certificate of a file that corresponds to the aqFileInfoObj object.

Declaration

aqFileInfoObj.CertificateInfo

Read-Only Property An aqFileCertificateInfo object
aqFileInfoObj An expression, variable or parameter that specifies a reference to an aqFileInfo object

Applies To

The property is applied to the following object:

Property Value

An aqFileCertificateInfo object that provides information about the certificate.

If the file does not have certificate information, the property returns the aqFileCertificateInfo object whose properties have empty values (empty strings and so on). If you try to call properties or methods on such a certificate from your tests, an error will occur.

Example

The following example demonstrates how you can obtain information about a files’s certificate and post this information to the test log.

JavaScript, JScript

function CertificateInfoSample()
{
  var fileName = Sys.Process("TestComplete").Path; // Specify the file name here
  var certInfo = aqFileSystem.GetFileInfo(fileName).CertificateInfo;

  Log.Message("Version: " + certInfo.Version);
  Log.Message("Serial number: " + certInfo.SerialNumber);
  Log.Message("Signature algorithm: " + certInfo.Algorithm);
  Log.Message("Issuer: " + certInfo.Issuer);
  Log.Message("Valid from: " + aqConvert.DateTimeToFormatStr(certInfo.NotBefore, "%#c"));
  Log.Message("Valid to: " + aqConvert.DateTimeToFormatStr(certInfo.NotAfter, "%#c"));
  Log.Message("Subject: " + certInfo.Subject);
  Log.Message("Public key: " + certInfo.PublicKey);
}

Python

def CertificateInfoSample():
  fileName = Sys.Process("TestComplete").Path # Specify the file name here
  certInfo = aqFileSystem.GetFileInfo(fileName).CertificateInfo
  Log.Message("Version: " + certInfo.Version)
  Log.Message("Serial number: " + certInfo.SerialNumber)
  Log.Message("Signature algorithm: " + certInfo.Algorithm)
  Log.Message("Issuer: " + certInfo.Issuer)
  Log.Message("Valid from: " + aqConvert.DateTimeToFormatStr(certInfo.NotBefore, "%#c"))
  Log.Message("Valid to: " + aqConvert.DateTimeToFormatStr(certInfo.NotAfter, "%#c"))
  Log.Message("Subject: " + certInfo.Subject)
  Log.Message("Public key: " + certInfo.PublicKey)

VBScript

Sub CertificateInfoSample
  Dim fileName, certInfo

  fileName = Sys.Process("TestComplete").Path ' Replace this expression with your file name
  Set certInfo = aqFileSystem.GetFileInfo(fileName).CertificateInfo

  Log.Message "Version: " & certInfo.Version
  Log.Message "Serial number: " & certInfo.SerialNumber
  Log.Message "Signature algorithm: " & certInfo.Algorithm
  Log.Message "Issuer: " & certInfo.Issuer
  Log.Message "Valid from: " & aqConvert.DateTimeToFormatStr(certInfo.NotBefore, "%#c")
  Log.Message "Valid to: " & aqConvert.DateTimeToFormatStr(certInfo.NotAfter, "%#c")
  Log.Message "Subject: " & certInfo.Subject
  Log.Message "Public key: " & certInfo.PublicKey
End Sub

DelphiScript

procedure CertificateInfoSample;
var fileName, certInfo;
begin
  fileName := Sys.Process('TestComplete').Path; // Replace this expression with your file name
  certInfo := aqFileSystem.GetFileInfo(fileName).CertificateInfo;

  Log.Message('Version: ' + certInfo.Version);
  Log.Message('Serial number: ' + certInfo.SerialNumber);
  Log.Message('Signature algorithm: ' + certInfo.Algorithm);
  Log.Message('Issuer: ' + certInfo.Issuer);
  Log.Message('Valid from: ' + aqConvert.DateTimeToFormatStr(certInfo.NotBefore, '%#c'));
  Log.Message('Valid to: ' + aqConvert.DateTimeToFormatStr(certInfo.NotAfter, '%#c'));
  Log.Message('Subject: ' + certInfo.Subject);
  Log.Message('Public key: ' + certInfo.PublicKey);
end;

C++Script, C#Script

function CertificateInfoSample()
{
  var fileName = Sys["Process"]("TestComplete")["Path"]; // Replace this expression with your file name
  var certInfo = aqFileSystem["GetFileInfo"](fileName)["CertificateInfo"];

  Log["Message"]("Version: " + certInfo["Version"]);
  Log["Message"]("Serial number: " + certInfo["SerialNumber"]);
  Log["Message"]("Signature algorithm: " + certInfo["Algorithm"]);
  Log["Message"]("Issuer: " + certInfo["Issuer"]);
  Log["Message"]("Valid from: " + aqConvert["DateTimeToFormatStr"](certInfo["NotBefore"], "%#c"));
  Log["Message"]("Valid to: " + aqConvert["DateTimeToFormatStr"](certInfo["NotAfter"], "%#c"));
  Log["Message"]("Subject: " + certInfo["Subject"]);
  Log["Message"]("Public key: " + certInfo["PublicKey"]);
}

See Also

aqFileCertificateInfo Object

Highlight search results