ClientCertificate Object

Applies to TestComplete 14.72, last modified on April 22, 2021

Description

The ClientCertificate object provides a program interface to X.509 certificate that the client uses to authenticate itself to the service tested with the Web Service project element.

You obtain the ClientCertificate object in scripts through the ClientCertificate property of the WebServiceCredentials object.

The ClientCertificate object provides a scripting interface to X.509 certificate credentials. The object contains two methods that help you configure the credential object that the client uses to authenticate itself to the service.

Members

Example

The code snippet below demonstrates how you can use the SetCertificateEx method to define the certificate by its serial number.

JavaScript, JScript

function ServiceSertificate()
{
  var MyWebService, Crd, Certificate;
  
  // Obtain the tested web service
  MyWebService = WebServices.SampleWebService;
  
  // Call a web service Credentials property
  Crd = MyWebService.Credentials;
  
  // Obtain the client certificate object
  Certificate = Crd.ClientCertificate;
  
  // Defines the client certificate
  Certificate.SetCertificateEx(slLocalMachine, snMy, ftFindBySerialNumber, "11 b3 a6 b8 85 45 bd a4 41 91 91 33 ff 32 5d c3");
}

Python

def ServiceSertificate():
  # Obtain the tested web service
  MyWebService = WebServices.SampleWebService
  # Call a web service Credentials property 
  Crd = MyWebService.Credentials
  # Obtain the client certificate object
  Certificate = Crd.ClientCertificate
  # Defines the client certificate
  Certificate.SetCertificateEx(slLocalMachine, snMy, ftFindBySerialNumber, "11 b3 a6 b8 85 45 bd a4 41 91 91 33 ff 32 5d c3")

VBScript

Sub ServiceSertificate

  Dim MyWebService, Crd, Certificate
  
  ' Obtain the tested web service
  Set MyWebService = WebServices.SampleWebService
  
  ' Call a web service Credentials property
  Set Crd = MyWebService.Credentials
  
  ' Obtain the client certificate object
  Set Certificate = Crd.ClientCertificate
  
  ' Defines the client certificate
  Call Certificate.SetCertificateEx(slLocalMachine, snMy, ftFindBySerialNumber, "11 b3 a6 b8 85 45 bd a4 41 91 91 33 ff 32 5d c3")

End Sub

DelphiScript

function ServiceSertificate();
var MyWebService, Crd, Certificate: OleVariant;
begin
  
  // Obtain the tested web service
  MyWebService := WebServices.SampleWebService;
  
  // Call a web service Credentials property
  Crd := MyWebService.Credentials;
  
  // Obtain the client certificate object
  Certificate := Crd.ClientCertificate;
  
  // Defines the client certificate
  Certificate.SetCertificateEx(slLocalMachine, snMy, ftFindBySerialNumber, '11 b3 a6 b8 85 45 bd a4 41 91 91 33 ff 32 5d c3');

end;

C++Script, C#Script

function ServiceSertificate()
{
  var MyWebService, Crd, Certificate;
  
  // Obtain the tested web service
  MyWebService = WebServices["SampleWebService"];
  
  // Call a web service Credentials property
  Crd = MyWebService["Credentials"];
  
  // Obtain the client certificate object
  Certificate = Crd["ClientCertificate"];
  
  // Defines the client certificate
  Certificate["SetCertificateEx"]( slLocalMachine, snMy, ftFindBySerialNumber, "11 b3 a6 b8 85 45 bd a4 41 91 91 33 ff 32 5d c3" );
}

See Also

ClientCertificate Property
WebServiceCredentials Object
Testing Web Services

Highlight search results