Skip to content

Commit

Permalink
feat(base-driver): Add server support of TLS and SPDY protocols (#19105)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Sep 8, 2023
1 parent c87596b commit 5926919
Show file tree
Hide file tree
Showing 10 changed files with 388 additions and 9 deletions.
213 changes: 210 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions packages/appium/docs/en/guides/tls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Starting the Server with SSL/TLS/SPDY support
---

## Command Line Arguments

Since version 2.2 of the server there is a possibility to start it with SSL/TLS support. In order to enable secure connections to the server you need to provide the following command line arguments:

```bashs
appium server --ssl-cert-path=/path/to/cert.pem --ssl-key-path=/path/to/key.pem
```

Both arguments must be provided and should contain paths to a valid [X509 PEM](https://www.ssl.com/guide/pem-der-crt-and-cer-x-509-encodings-and-conversions/) certificate and its corresponding private key.

After the server is started use the `https` protocol and a client supporting SSL/TLS or [SPDY](https://en.wikipedia.org/wiki/SPDY) to communicate to it.

### Supported Features

Once a secure server socket is established it supports the following protocols: `['h2', 'spdy/3.1', 'spdy/3', 'spdy/2', 'http/1.1', 'http/1.0']`. See [the SPDY node module documentation](https://www.npmjs.com/package/spdy) to get more details about its features. All insecure client connections will be rejected by the server.

### Self-Signed Certificates

Use the following command in order to generate a self-signed certificate/key pair:

```bash
openssl req -nodes -new -x509 -keyout key.pem -out cert.pem -subj "/C=US/ST=State/L=City/O=company/OU=Com/CN=www.testserver.local"
```

Feel free to change the value of `-subj` in the command above with your matching details. The server should work just fine with a self-signed certificate, although you need to take care about a proper client setup, e.g. make sure it does not reject unauthorized certificates.
3 changes: 2 additions & 1 deletion packages/appium/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ async function main(args) {
});
}

const protocol = 'secure' in server && server.secure ? 'https' : 'http';
const address = net.isIPv6(parsedArgs.address) ? `[${parsedArgs.address}]` : parsedArgs.address;
logServerAddress(`http://${address}:${parsedArgs.port}${normalizeBasePath(parsedArgs.basePath)}`);
logServerAddress(`${protocol}://${address}:${parsedArgs.port}${normalizeBasePath(parsedArgs.basePath)}`);

driverConfig.print();
pluginConfig.print([...pluginClasses.values()]);
Expand Down

0 comments on commit 5926919

Please sign in to comment.