Encryption¶
What’s in this document?
Encryption in transit¶
All network traffic between the clients and GraphDB and between the different GraphDB nodes (in case of a cluster topology) can be performed over either HTTP or HTTPS protocols. It is highly advisable to encrypt the traffic with SSL/TLS because it has numerous security benefits.
Configuring a GraphDB instance with SSL¶
As GraphDB runs on embedded Tomcat server, the security configuration is standard with a few exceptions. See more in the official Tomcat documentation on how to enable SSL/TLS.
SSL can be enabled by configuring the following parameter:
graphdb.connector.ssl.enabled = true
GraphDB uses the Java implementation of SSL, which requires a configured key in the Java keystore.
graphdb.connector.ssl.certificateKeystoreFile = <path to the keystore file>
graphdb.connector.ssl.certificateKeystorePassword = <secret>
graphdb.connector.ssl.certificateKeyAlias = graphdb
graphdb.connector.ssl.certificateKeyPassword = <secret>
If you have no Java keystore, you can generate one by using one of the following methods:
Option one — generate a self-signed key. You would have to trust the certificate in all clients, including all nodes that run in a different JVM.
$ keytool -genkey -alias graphdb -keyalg RSA -keystore \path\to\my\keystore
Option two — convert a third party trusted OpenSSL certificate to PKCS12 key and then import to the Java keystore.
openssl pkcs12 -export -in mycert.crt -inkey mykey.key
-out mycert.p12 -name tomcat -CAfile myCA.crt
-caname root -chain
For any additional encryption information, please refer to the Encryption section or, since GraphDB runs in an embedded Tomcat, to the Tomcat ssl documentation.
In addition to the above settings, you can set any Tomcat Connector attribute through a property:
graphdb.connector.<attribute> = xxx
Currently, GraphDB does not support configuration of the SSLHostConfig part of the Tomcat configuration. So when configuring SSL, please refer to the Connector attributes and not the SSLHostConfig ones. See the Tomcat attributes documentation for more information.
Certificate trust¶
After configuring the GraphDB instance with SSL, certificate trust should be set up between the GraphDB node and all client nodes communicating with it. Certificate trust can be provided in one of two ways:
Use certificates signed by a trusted certification authority¶
This way, you will not need any additional configuration and the clients will not get security warning when connecting to the server. The drawback is that these certificates are usually not free and you need to work with a third-party CA. We will not look at this option in more detail as creating such a certificate is highly dependent on the CA.
Use self-signed certificates¶
The benefit is that you generate these certificates yourself and they do not need to be signed by anyone else. However, the drawback is that by default, the nodes will not trust each others’ certificates.
If you generate a separate self-signed certificate for each node in the communication, this certificate would have to be present in the Java Truststores of all other nodes. You can do this by either adding the certificate to the default Java Truststore or specifying an additional Truststore when running GraphDB. Information on how to generate a certificate, add it to a Truststore, and make the JVM use this Truststore can be found in the official Java documentation.
However, this method introduces a lot of configuration overhead. Therefore, we recommend that instead of separate certificates for each node, you generate a single self-signed certificate and use it on all nodes. GraphDB extends the standard Java TrustManager, so it will automatically trust its own certificate. This means that if all nodes involved in the communication are using a shared certificate, there would be no need to add it to the Truststore.
Another difference from the standard Java TrustManager is that GraphDB has the option to disregard the hostname when validating the certificates. If this option is disabled, it is recommended to add all possible IPs and DNS names of all nodes that will be using the certificate as Subject Alternative Names when generating the certificate (wildcards can be used as well).
Both options for trusting your own certificate and skipping the hostname validation are configurable from the graphdb.properties file:
graphdb.http.client.ssl.ignore.hostname—falseby default
graphdb.http.client.ssl.trust.own.certificate—trueby default
Encryption at rest¶
You can also encrypt your data at repository level. GraphDB implements encryption per repository while managing master key at the instance level. Each repository has a Data Encryption Key (DEK) used to encrypt individual entity values using AES-256-GCM. Each value is encrypted independently, with an unique IV randomly generated.
All encryption metadata is recorded in an append-only encryption.manifest file, which contains the wrapped DEK, its version, and the identifier or fingerprint of the master key used to wrap it. The DEKs can be rotated without rewriting the entity pool, and a new DEK is generated for future writes and added to the manifest. Changing the master key is supported by unwrapping the DEK with the old key and rewrapping it with the new key. Existing encrypted values remain untouched in both cases.
By separating DEKs per repository and maintaining an instance-level master key, the system achieves a secure, low-overhead encryption approach that is flexible.
When Creating a repository, you can select the option for the repository to be encrypted. Once a repository has been created, you cannot change whether it is encrypted or not.
If encryption at rest is not used, we recommend you to implement some kind of disk encryption on your GraphDB server. There are multiple third-party solutions that can be used. GraphDB has been tested on LUKS-encrypted hard drive, and no noticeable performance impact has been observed. However, please keep in mind that such may be present, as it is highly dependent on your specific use case.
Warning
If for some reason the manifest file is lost or corrupted on the file system, all data will be permanently lost, even if you still have the master key. It is impossible to restore the data using only the master key.
See also
Creating and editing repositories for further details on how to create a GraphDB repository
Configure a repository through the GraphDB Workbench for a full list of the configuration parameters of a repository.
Encryption at rest can also affect the backup and restore processes — the Backup and restore page outlines all necessary steps and important scenarios when creating a backup of an encrypted repository or restoring a backup that is encrypted.
Configuring the master key¶
GraphDB supports encryption via a 256-bits master key that can be set in one of two ways:
File-based master key, where the file contains the raw (binary) master key bits (256-bits for AES-256)
A master key from a configured PKCS12 keystore, where
GRAPHDB_ENCRYPTION_MASTER_KEY_ALIAS(graphdb.data.encryption.keystore.alias) specifies the alias of the secret key entry in the keystore. GraphDB uses this alias to retrieve the actual 256-bits master key
The type of the master key must be specified through the graphdb.data.encryption.type property, which takes either file or pkcs12 as value. The following two sections outline examples for both file-based master key configuration and PKCS12 keywstore-configured master key.
Note
When setting up a cluster, all nodes have same encryption configuration for the master key (with a checksum on encryption key). Repository configurations are directly propagated with encryption settings (config.ttl).
If master key has changed it is the user’s responsibility to make sure all instances have same master encryption key. See the Changing the master key procedure below.
File-based master key¶
graphdb.data.encryption.type—filegraphdb.data.encryption.file— the path to the master key file
Master key from a configured PKCS12 keystore¶
graphdb.data.encryption.type—pkcs12graphdb.data.encryption.file— the path to the master key filegraphdb.data.encryption.keystore.password— the password for the keystoregraphdb.data.encryption.keystore.alias— the alias of the master key as configured by the keystore
All indexes and entities are stored in binary format on the hard drive. It should be noted that the data from them can be easily extracted in case somebody gains access to the data directory.
Changing the master key¶
There are three main steps that are involved in performing a master key change. The master key rotation procedure requires downtime.
If in a cluster configuration, this procedure must be applied to each node of the cluster, and each of those steps must be carried out for each node of the cluster before moving onto the next step. You should not restart the instances of a cluster until all of the nodes have been updated.
Stop GraphDB.
Use the storage-tool to replace and update each repository’s
encryption.manifestfile.bin/storage-tool replace-master-key --storage /<path-to-repo>/storage --old-master-key /<path-to-the-old-master-key/> --new-master-key <path-to-the-new-master-key>/Start GraphDB, with the configuration properties pointing to the new master key.
Upon initialization, encrypted repositories will validate whether the master key fingerprint matches the one stored in the encryption manifest. The GraphDB instance will start using the new master key, all DEKs for all encrypted repositories will be stored encrypted by the new master key. If there is a mismatch (which can happen if the steps is not carried out in order), the repository will not initialize.
DEK rotation¶
Using an API call, you can rotate your DEKs without changing the master key:
curl -X POST 'http://graphdb.example.com:7200/rest/repositories/<repostioryName>/rotate-data-encryption-key
A new DEK will be generated for the specified repo (and added to the manifest file). Data that is already encryptes will remain encrypted with the old DEK(s), and henceforth encrypted data will be encrypted with the newly generated DEK.
Note
Each repo’s DEKs are independent from one another. You are not required to rotate DEKs for all repos at one and the same time.