| 1 |
# WPT Test Certificates |
| 2 |
|
| 3 |
The web-platform-tests project maintains a set of SSL certificates to allow |
| 4 |
contributors to execute tests requiring HTTPS locally. |
| 5 |
|
| 6 |
## Trusting Root CA |
| 7 |
|
| 8 |
To prevent browser SSL warnings when running HTTPS tests locally, the |
| 9 |
web-platform-tests Root CA file `cacert.pem` in the `tools/certs/` directory |
| 10 |
must be added as a trusted certificate in your OS/browser. |
| 11 |
|
| 12 |
For Firefox, go to about:preferences and search for "certificates". |
| 13 |
|
| 14 |
For browsers that use the Certificate Authorities of the underlying OS, such as |
| 15 |
Chrome and Safari, you need to adjust the OS. For macOS, go to Keychain Access |
| 16 |
and add the certificate under **login**. |
| 17 |
|
| 18 |
**NOTE**: The CA should not be installed in any browser profile used |
| 19 |
outside of tests, since it may be used to generate fake |
| 20 |
certificates. For browsers that use the OS certificate store, tests |
| 21 |
should therefore not be run manually outside a dedicated OS instance |
| 22 |
(e.g. a VM). To avoid this problem when running tests in Chrome or |
| 23 |
Firefox, use `wpt run`, which disables certificate checks and therefore |
| 24 |
doesn't require the root CA to be trusted. |
| 25 |
|
| 26 |
## Regenerating certificates |
| 27 |
|
| 28 |
The easiest way to regenerate the pregenerated certificates is to the |
| 29 |
the command |
| 30 |
|
| 31 |
``` |
| 32 |
wpt regen-certs |
| 33 |
``` |
| 34 |
|
| 35 |
By default this will not generate new certificates unless the existing |
| 36 |
ones are about to expire. In cases where the certificates need to be |
| 37 |
updated anyway (e.g. because the server configuration changed), this |
| 38 |
can be overridden with `--force`. |
| 39 |
|
| 40 |
Generating the certificates requires OpenSSL to be installed. |
| 41 |
|
| 42 |
### Implementation Details |
| 43 |
|
| 44 |
If you wish to manually generate new certificates for any reason, it's |
| 45 |
possible to use OpenSSL when starting the server, or starting a test |
| 46 |
run, by providing the `--ssl-type=openssl` argument to the `wpt serve` |
| 47 |
or `wpt run` commands. |
| 48 |
|
| 49 |
If you installed OpenSSL in such a way that running `openssl` at a |
| 50 |
command line doesn't work, you also need to adjust the path to the |
| 51 |
OpenSSL binary. This can be done by adding a section to `config.json` |
| 52 |
like: |
| 53 |
|
| 54 |
``` |
| 55 |
"ssl": {"openssl": {"binary": "/path/to/openssl"}} |
| 56 |
``` |
| 57 |
|
| 58 |
### Windows-specific Instructions |
| 59 |
|
| 60 |
For Windows users, the easiest approach is likely to be using |
| 61 |
[WSL](https://docs.microsoft.com/en-us/windows/wsl/) and generate |
| 62 |
certificates in a Linux environment. However it is possible to install |
| 63 |
OpenSSL and generate the certificates without using WSL. |
| 64 |
|
| 65 |
[Shining Light](https://slproweb.com/products/Win32OpenSSL.html) |
| 66 |
provide a convenient installer that is known to work, but requires a |
| 67 |
little extra setup: |
| 68 |
|
| 69 |
Run the installer for Win32_OpenSSL_v1.1.0b (30MB). During installation, |
| 70 |
change the default location for where to Copy OpenSSL Dlls from the |
| 71 |
System directory to the /bin directory. |
| 72 |
|
| 73 |
After installation, ensure that the path to OpenSSL (typically, |
| 74 |
this will be `C:\OpenSSL-Win32\bin`) is in your `%Path%` |
| 75 |
[Environment Variable](http://www.computerhope.com/issues/ch000549.htm). |
| 76 |
If you forget to do this part, you will most likely see a 'File Not Found' |
| 77 |
error when you start wptserve. |
| 78 |
|
| 79 |
Finally, set the path value in the server configuration file to the |
| 80 |
default OpenSSL configuration file location. To do this, create a file |
| 81 |
called `config.json`. Then add the OpenSSL configuration below, |
| 82 |
ensuring that the key `ssl/openssl/base_conf_path` has a value that is |
| 83 |
the path to the OpenSSL config file (typically this will be |
| 84 |
`C:\\OpenSSL-Win32\\bin\\openssl.cfg`): |
| 85 |
|
| 86 |
``` |
| 87 |
{ |
| 88 |
"ssl": { |
| 89 |
"type": "openssl", |
| 90 |
"encrypt_after_connect": false, |
| 91 |
"openssl": { |
| 92 |
"openssl_binary": "openssl", |
| 93 |
"base_path: "_certs", |
| 94 |
"force_regenerate": false, |
| 95 |
"base_conf_path": "C:\\OpenSSL-Win32\\bin\\openssl.cfg" |
| 96 |
}, |
| 97 |
}, |
| 98 |
} |
| 99 |
``` |