BrowserImportCertificate Function

Action

Imports the client certificate from a file into the certificate store of the operating system for later use by Internet Explorer. This function is similar to manually importing certificate files. Note that certificates are shared resources in the operating system. In other words, all Internet Explorer instances access the same certificate store.

The certificate APIs work with Microsoft Windows 7 or later, Microsoft Windows Server 2008 R2 or later, and Internet Explorer 8 or later.

Note: This function only works with Internet Explorer.

Include file

BrowserAPI.bdh

Syntax

BrowserImportCertificate( sFilename        : in  string,
                          sPassword        : in  string,
                          sCertificatename : out string optional,
                          sCertstore       : in  string optional ): boolean;
Parameter Description
sFilename The file containing the certificate (PFX or P12).
sPassword The password for decrypting the contents of the file.
sCertificatename Optional: The name of the client certificate.
sCertstore Optional: The certificate store name. When this parameter is not specified certificates are imported into the My store, available on the certificate tab's Personal tab.

Return Value

  • true if successful

  • false otherwise

Example

Note: The following example does not work out-of-the-box, as you first need to set up a certificate in order to execute actions on it.
benchmark SilkPerformerRecorder

use "Kernel.bdh"
use "BrowserAPI.bdh"

dcluser
  user
    VUser
  transactions
    TInit           : begin;
    TMain           : 1;

var

dclrand

dcltrans
  transaction TInit
  begin
  end TInit;

  transaction TMain
  var
    sCertificate : string;
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);
    
    // import a certificate into the default certificate store
    BrowserImportCertificate("C:\Users\johns\Desktop\BDLT\johns.pfx","password", sCertificate);
    // select the newly imported certificate
    BrowserSetCertificate("John Smith");
    // navigate to the secure site
    BrowserNavigate("https://testsite/clientcert/servervar.asp");
  end TMain;