In case a client certificate is required to connect to the site to be tested during a MagicPod browser test, the client certificate can be automatically selected according to preconfigured settings.
Table of Contents
Support target
Execution environment
Currently, this only supports Chrome in the Cloud environment or Chrome for local PC environment (Mac only).
- There are no plans to support external Cloud services (SauceLabs, BrowserStack).
-
Although there are no current plans to support other local PC environments (Windows PC Chrome or other browsers), we have created a feature request for this functionality, which is planned for future development:
Client Certificate Support (Windows PC Chrome, etc.)
By voting for the above request, you can help us prioritize future feature development and also receive a notification when the feature becomes available. Please refer to this page for instructions on how to vote.
Types of certificate files
This only supports PKCS #12 type (with .pfx or .p12 extension).
Reference: Certificate file types
Since MagicPod 1.0.0, certificate files with old cipher algorithms (like RC2, RC4, RC5, DES, MD2, MD4, MDC2, RMD160, CAST5, Blowfish, IDEA, SEED) cannot be uploaded. Please use newer algorithms to upload new files. You can keep using already uploaded files regardless of the cipher algorithm.
Setup method (Cloud)
Open the test run settings dialog and set the Environment option to Cloud.
Click the Open advanced button to show the Client certificates settings item.
For Cloud environments, the certificate(s) used for the test must be uploaded to the MagicPod Server.
When you click the Manage certificates button, the dialog box for registration will be displayed, so register the file.
After selecting the file, enter the password for the certificate file. This password is required to install the certificate on the machine for running the test on the Cloud.
After completing registration, click the Close button to return to the test run settings dialog.
After closing the dialog box, select the certificate you have just registered in the pull-down menu for selecting certificates. Also, enter the host name of the site where you wish to use this certificate in the column where Enter a host name is written.
The certificate is selected on the host you enter and its subdomains. For example, if you enter “example.com”, it also applies to a URL such as “https://test.example.com/login”. Do not enter “https://”, a path (such as “/login”), or a query. If a port number is needed, enter it like “test.example.com:8443”. If the field is left empty, the certificate is selected on every site.
This completes the settings. If you run the test in this state, the client certificate will be automatically selected during execution.
Setup method (Local PC)
If you are using a client certificate for a local PC test on Mac, install the certificate on the PC in advance.
Open the test run settings dialog and set the Environment option to Local PC.
Click the Open advanced button to show the Client certificates settings item.
Unlike in the Cloud, there is no need to store the certificate on the Server, but you will need to enter the issuer name of the certificate instead. If you do not know the issuer name, you can look it up using the following procedure. (From the second use onward, if you already know the issuer name, you can skip the following steps.)
If you click the Get issuer name button, the following dialog box will be displayed, so upload the certificate file according to the instructions and enter your password. The password you enter here is the same password as when you installed the certificate on the local PC. This is necessary for analyzing the certificate and acquiring the issuer name. The certificate itself is uploaded to the Server once and analyzed, but as it is not required after that point, it will not be stored on the Server.
Once the analysis completes, the following message will be displayed.
The analyzed issuer name is stored on the clipboard, so enter this by pasting it into the Enter issuer name column. Also, enter the host name of the site where you wish to use this certificate in the column where Enter a host name is written.
The certificate is selected on the host you enter and its subdomains. For example, if you enter “example.com”, it also applies to a URL such as “https://test.example.com/login”. Do not enter “https://”, a path (such as “/login”), or a query. If a port number is needed, enter it like “test.example.com:8443”. If the field is left empty, the certificate is selected on every site.
This completes the settings. If you run the test in this state, the client certificate will be automatically selected during execution.
Using Different Certificates for Different Sites
To use different client certificates for different sites, enter in the “URL pattern” field of each certificate the host name of the site where that certificate is used.
Note that certificates cannot be used separately per site in these cases:
- Several certificates are set for the same host
- Several certificates from the same issuer are set
If it does not work as expected, please contact MagicPod support.
If a URL Pattern Other Than a Host Name Is Set
Since MagicPod 1.74.0, only a host name can be set as the “URL pattern” of a client certificate. Previously, you could enter part of a URL as a partial match. If a value other than a host name is set, an error message like the following appears when a test run starts or when the test run settings are saved.
The client certificate URL pattern "https://test.example.com/login" is not a host name. Enter a host name such as "example.com".
In that case, open the test run settings and replace the value shown in the error message with a host name.
- “https://test.example.com/login” → “test.example.com” or “example.com”
- Part of a URL such as “example” → a host name such as “example.com”
If the certificate selection dialog is prompted in a local environment test
Even if you set the client certificate on MagicPod as described above, Chrome may show a dialog asking the user to select a client certificate, depending on the Mac you use.
You can register which certificate to use on which webpage in Chrome by following the steps below. The setting remains unless you delete it.
1. Quit Chrome
Select "Quit Google Chrome"
2. Confirm the existing setting
Open a terminal app and run the following command
defaults read com.google.Chrome AutoSelectCertificateForUrls
- If "does not exist" is shown: There is no existing setting on your PC.
- If any setting is shown: Your PC already has a rule to select certificates automatically.
3. Register the rule
This command overwrites the existing rule. If an existing rule is found in the above step and you'd like to keep it, refer to the "How to register multiple certificate rules" section.
Run the following command to register the certificate. You can find the issuer name using the "Get issuer name" button.
defaults write com.google.Chrome AutoSelectCertificateForUrls -array \
'"{\"pattern\":\"[*.]<HOST NAME>\",\"filter\":{\"ISSUER\":{\"CN\":\"<ISSUER NAME>\"}}}"'Example
defaults write com.google.Chrome AutoSelectCertificateForUrls -array \
'"{\"pattern\":\"[*.]example.com\",\"filter\":{\"ISSUER\":{\"CN\":\"My Client Root CA\"}}}"'For an IP address, specify it without [*.], e.g., "pattern":"192.168.0.1".
How to register multiple certificate rules
Write all rules in a space-separated format. To reiterate, this command overwrites the existing setting, so please input all rules in one command.
defaults write com.google.Chrome AutoSelectCertificateForUrls -array \
'"{\"pattern\":\"[*.]example.com\",\"filter\":{\"ISSUER\":{\"CN\":\"CA-A\"}}}"' \
'"{\"pattern\":\"[*.]another.com\",\"filter\":{\"ISSUER\":{\"CN\":\"CA-B\"}}}"'
4. Check the registration result
Launch Google Chrome and navigate to "chrome://policy". If the registered rule appears in AutoSelectCertificateForUrls, the registration was successful.
Note
defaults delete com.google.Chrome AutoSelectCertificateForUrls