-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Motivation I'm writing an article on how easy it's suppose to be to setup TLS/SSL with ScyllaDB and one of the examples which I want to add is using JS. ATM the driver only support the Certificate without Keys/Truststore and this pull request adds this specific support. ```js // Before const cluster = new Cluster({ nodes, ssl: { caFilepath: "/your/path/to/certificates/client_truststore.pem", verifyMode: VerifyMode.Peer, } }); // After const cluster = new Cluster({ nodes, ssl: { enabled: true, // Feature Flag truststoreFilepath: "/your/path/to/certificates/client_cert.pem", // Added field privateKeyFilepath: "/your/path/to/certificates/client_key.pem", // Added field caFilepath: "/your/path/to/certificates/client_truststore.pem", verifyMode: VerifyMode.Peer, } }); ``` IMHO I don't know if this feature flag is useful, but at least for me seems more like a easy way to turn it on/off. So, please let me know your thoughts on that. > [!TIP] > You can test with [this sample](https://github.com/DanielHe4rt/scylladb-role-tls-auth) by running `make setup` and then pointing your keys **absolute path** at the SSL object. Also, don't forget to switch your port to `9142` at the connection string. ## Changes - [x] TLS/SSL with Keystore and Private Keys - [x] Feature flag to enable/disable SSL. - [x] Simple example on how to use it.
- Loading branch information
1 parent
c389187
commit 75a8336
Showing
3 changed files
with
112 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {Cluster, VerifyMode} from "../index.js" | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["localhost:9142"]; | ||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ | ||
nodes, | ||
ssl: { | ||
enabled: true, | ||
truststoreFilepath: "/your/path/to/certificates/client_cert.pem", | ||
privateKeyFilepath: "/your/path/to/certificates/client_key.pem", | ||
caFilepath: "/your/path/to/certificates/client_truststore.pem", | ||
verifyMode: VerifyMode.Peer, | ||
} | ||
}); | ||
|
||
const session = await cluster.connect(); | ||
|
||
interface ConnectedClient { | ||
address: String, | ||
port: number, | ||
username: String, | ||
driver_name: String, | ||
driver_version: String, | ||
} | ||
|
||
// @ts-ignore | ||
let result = await session.execute<ConnectedClient>("SELECT address, port, username, driver_name, driver_version FROM system.clients"); | ||
|
||
console.log(result) | ||
// [ | ||
// { | ||
// address: '127.0.0.1', | ||
// driver_name: 'scylla-rust-driver', | ||
// driver_version: '0.10.1', | ||
// port: 58846, | ||
// username: 'developer' | ||
// } | ||
// ] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters