Get your setup working faster. Join our Discord for optimisation tips from elite testers.Join our Discord
Test using PFX certificates
You can upload and install .pfx (Personal Information Exchange) certificates on BrowserStack Automate to test websites and workflows that require client-certificate authentication.
To start testing with .pfx certificates, contact BrowserStack Support to have your certificates reviewed and validated.
Use cases
Testing with .pfx certificates is useful in scenarios such as:
Testing websites that require a valid client certificate for authentication.
Verifying workflows that depend on certificate-based access.
Conducting compatibility checks for advisory portals that require authentication.
Ensuring that certificate installation works across different operating systems and browsers.
Supported operating systems and browsers
The following operating systems and browsers support .pfx certificates:
Operating System
Versions
Browsers
Windows
Windows 11
Chrome
macOS
Sequoia, Tahoe, Golden Gate
Chrome
Upload your file to BrowserStack
Run the following upload media cURL command to upload your file to BrowserStack servers:
const{Builder,By,until}=require('selenium-webdriver');const{Capabilities}=require('selenium-webdriver');constfs=require('fs');const{debug}=require('console');(asyncfunctionrunSelenium(){constusername=""constaccessKey=""constcapabilities={browserName:"Chrome",browserVersion:"latest",'bstack:options':{os:"OS X",osVersion:"Sequoia",userName:"",accessKey:"",projectName:"test-cert",buildName:"pfx cert check",sessionName:"session performance test3",accessibility:true,selfHeal:true,"chromeOptions":{"prefs":{"profile.managed_auto_select_certificate_for_urls":[JSON.stringify({"pattern":"https://client.badssl.com",// this is a public website"filter":{"SUBJECT":{"CN":"BadSSL Client Certificate"}}})]}},debug:true,uploadMedia:['media://xyz'],customCertificate:{"media://xyz":{"password":"xyz",}}}};letdriver;try{driver=awaitnewBuilder().usingServer(`https://${username}:${accessKey}@hub-cloud.browserstack.com/wd/hub`).withCapabilities(capabilities).build();console.log("connected done")awaitdriver.get("https://client.badssl.com/");awaitdriver.sleep(2000);console.log("Taking screenshot...");// 1. Take the screenshotconstimage=awaitdriver.takeScreenshot();// 2. Save the Base64 string as a PNG filefs.writeFileSync("screenshotpfx.png",image,"base64");console.log("Screenshot saved to screenshot.png");console.log("login done")}catch(err){console.error("Test failed:",err.message);}finally{if(driver){awaitdriver.quit();}}})();
importosimporttimeimportjsonfromseleniumimportwebdriverUSERNAME=""ACCESS_KEY=""HUB_URL=f"https://{USERNAME}:{ACCESS_KEY}@hub-cloud.browserstack.com/wd/hub"defrun_selenium_test():options=webdriver.ChromeOptions()bstack_options={"os":"OS X","osVersion":"Sequoia","projectName":"test-cert","buildName":"pfx cert check","sessionName":"python cert test","userName":USERNAME,"accessKey":ACCESS_KEY,"uploadMedia":["media://xyz"],"customCertificate":{"media://xyz":{"password":"badssl.com"}},"chromeOptions":{"prefs":{"profile.managed_auto_select_certificate_for_urls":[json.dumps({"pattern":"https://client.badssl.com","filter":{"SUBJECT":{"CN":"BadSSL Client Certificate"}}})]}}}# Add BrowserStack caps to options
options.set_capability("bstack:options",bstack_options)print("Connecting to BrowserStack...")driver=webdriver.Remote(command_executor=HUB_URL,options=options)print("Connected successfully!")driver.get("https://client.badssl.com/")time.sleep(3)driver.save_screenshot("screenshotpfx.png")print("Screenshot saved!")driver.quit()if__name__=="__main__":run_selenium_test()
<?phprequire_once('vendor/autoload.php');useFacebook\WebDriver\Remote\RemoteWebDriver;useFacebook\WebDriver\Remote\DesiredCapabilities;useFacebook\WebDriver\WebDriverException;classBrowserStackClientCertTest{privateconstUSERNAME="";privateconstACCESS_KEY="";// NOTE: HUB_URL is defined WITHOUT credentials hereprivateconstHUB_URL="https://hub-cloud.browserstack.com/wd/hub";publicstaticfunctionrunTest(){$driver=null;try{// 1. Base capabilities$capabilities=DesiredCapabilities::chrome();$capabilities->setCapability('browserVersion','126.0');// Use stable version// 2. bstack:options (MUST include 'user' and 'key' explicitly for Hub processing)$bstackOptions=['os'=>'OS X','osVersion'=>'Sequoia','userName'=>self::USERNAME,'accessKey'=>self::ACCESS_KEY,// Optional metadata'projectName'=>'test-cert','buildName'=>'pfx cert check','sessionName'=>'csharp certificate test','accessibility'=>true,'selfHeal'=>true,'debug'=>true,// --- Certificate and Media Configuration ---'uploadMedia'=>['media://xyz'],'customCertificate'=>['media://xyz'=>['password'=>'badssl.com']],"chromeOptions"=>['prefs'=>["profile.managed_auto_select_certificate_for_urls"=>[json_encode(["pattern"=>"https://client.badssl.com","filter"=>["SUBJECT"=>["CN"=>"BadSSL Client Certificate"]]])]]]];// 4. Attach capabilities$capabilities->setCapability('bstack:options',$bstackOptions);echo"Connecting to BrowserStack...\n";// 5. Build driver using clean HUB URL and rely on BStack capabilities for auth$driver=RemoteWebDriver::create(self::HUB_URL,$capabilities,300000,300000);echo"Connected successfully. Session ID: ".$driver->getSessionID().PHP_EOL;// 6. Run test$driver->get('https://client.badssl.com/');// simple sleep to let browser load and (hopefully) auto-select certificatesleep(5);// Take screenshot$imagePath='screenshotpfx.png';$driver->takeScreenshot($imagePath);echo"Screenshot saved to {$imagePath}\n";}catch(WebDriverException$e){error_log("WebDriverException: ".$e->getMessage());echo"WebDriverException: ".$e->getMessage().PHP_EOL;}catch(\Exception$e){error_log("Exception: ".$e->getMessage());echo"Exception: ".$e->getMessage().PHP_EOL;}finally{if($driver!==null){$driver->quit();}}}}BrowserStackClientCertTest::runTest();
require'rubygems'require'selenium-webdriver'# SET CHROME OPTIONSLITERAL_CERTIFICATE_PREFERENCE_STRING='{"pattern":"https://client.badssl.com","filter":{"SUBJECT":{"CN":"BadSSL Client Certificate"}}}'caps=Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions"=>{"prefs"=>{'profile.managed_auto_select_certificate_for_urls'=>[LITERAL_CERTIFICATE_PREFERENCE_STRING]}})# SET CAPABILITYcaps['browser']='Chrome'caps['browser_version']='130.0'caps['os']='Windows'caps['os_version']='11'caps["uploadMedia"]=["media://xyz"]caps["customCertificate"]={"media://xyz"=>{"password"=>"badssl.com"}}driver=Selenium::WebDriver.for(:remote,:url=>"http://#{USERNAME}:#{ACCESS_KEY}@hub-cloud.browserstack.com/wd/hub",:desired_capabilities=>caps)driver.navigate.to"https://client.badssl.com/"driver.quit
Did this page help you?
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback
Is this page helping you?
Yes
No
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked