Skip to main content
No Result Found

Test certificate based authentication

Test authentication using a .pfx certificate

The PFX certificate upload feature is currently in beta. To enable this feature, contact support.

You can upload your Personal Information Exchange (.pfx) certificates on BrowserStack devices for certificate-based authentication. After installing the certificate, you can sign in to the dependent apps without entering a password.

Supported file types and OS version

You can upload a non-media PFX file type up to 10 MB in size.

The following table shows the supported OS and devices to which you can upload your files for testing:

OS OS version
iOS v15 and above
Android v7 and above

BrowserStack supports the PFX certificate upload on Android devices with certain exceptions. For more information, contact us.

Upload your file to BrowserStack

Run the following upload media cURL command to upload your .pfx file to BrowserStack servers:

Request
Copy icon Copy

Here is a sample cURL response. It returns the media_url parameter value.

Response
Copy icon Copy

BrowserStack creates a Custom_Files folder in Files app → On My iPhone → Your app's directory. You can find the file under the App directory on your device.

Set the capability in test script

To use certificate based authentication, set the customCertificate capability. Here is an example to set this capability in your config file:

Copy icon Copy
Copy icon Copy

Set the browserstack.uploadMedia capability to the value of the media_url parameter returned in the API response as shown in the following code snippets:

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.uploadMedia", new String[]{"media://90c7a8h8dc82308108734e9a46c24d8f01de12881"});
var capabilities = {
	'browserstack.uploadMedia': ['media://90c7a8h8dc82308108734e9a46c24d8f01de12881']
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("browserstack.uploadMedia", new[] {"media://90c7a8h8dc82308108734e9a46c24d8f01de12881"});
$capabilities = new DesiredCapabilities();
$capabilities->setCapability("browserstack.uploadMedia", ["media://90c7a8h8dc82308108734e9a46c24d8f01de12881"]);
desired_cap = {
	'browserstack.uploadMedia': ['media://90c7a8h8dc82308108734e9a46c24d8f01de12881']
}
desired_caps = {
    'browserstack.uploadMedia': ['media://90c7a8h8dc82308108734e9a46c24d8f01de12881']
}

You can upload multiple certificates but you will only be able to use one certificate in a session for authentication.

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





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle