Password Encryption


openLooKeng manages configuration details in properties files of catalogs. These files may need to include values such as usernames, passwords and other strings, the password often required to be kept secret, that can’t be stored as plaintext. Here is a typical configuration file of a MySQL connector:

openLooKeng can be configured to enable password encryption, these passwords will be encrypted.


The asymmetric encryption algorithm (RSA) is used for encrypting password.


  • Public Key: for encryption, client can use public key to encrypt plaintext.
  • Private Key: for decryption, server store the private key as a keystore file in filesystem, and server can use private key to decrypt the ciphertext.

The user saves the public key and gives the private key to openLooKeng to decrypt the encrypted ciphertext.

The key suggested size of RSA is 3072 bits, the minimum is 2048 bits.


To enable password encryption, you need add these properties in the etc/

security.password.decryption-typeThe type of password decryption. Should be set to NONE or RSA.
security.key.manager-type=keystoreThe type of password encryption key storage. Should be set to keystore.
security.key.keystore-passwordThe password of keystore.
security.key.cipher-transformationsCipher.getInstance(transformations), the default value is ‘RSA/ECB/OAEPWITHSHA256AndMGF1Padding’ filesystem path of keystore file.

Use Case

Case 1. Create RSA key pair

You can use keytool to create a keystore, and get Public Key from the keystore, and use openssl to encrypt data with Public Key. And send the private key to openLooKeng server by restful api.

1. create a keystore, you have to use pkcs12:
keytool -genkeypair -alias alias -dname cn=openlookeng -validity 365 -keyalg RSA -keysize 2048 -keypass openlookeng -storetype jks -keystore keystore.jks -storepass openlookeng -deststoretype pkcs12

2. get Public Key from keystore, copy the public key into pub.key file:
keytool -list -rfc -keystore keystore.jks -storepass openlookeng | openssl x509 -inform pem -pubkey

3. use openssl to encrypt data with RSA/ECB/OAEPWITHSHA256AndMGF1Padding by Public Key:
openssl pkeyutl -encrypt -in data.txt -out result.en -pubin -inkey pub.key -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:SHA256 -pkeyopt rsa_mgf1_md:SHA256

4. get readable encrypted data by base64:
cat result.en | base64
after transfer the encrypted data by base64, you have to delete the '\n' from each line, and then you can get the final encrypted content.

5. private key 
keytool -v -importkeystore -srckeystore keystore.jks -srcstoretype jks -srcstorepass openlookeng -destkeystore server.pfx -deststoretype pkcs12 -deststorepass openlookeng -destkeypass openlookeng  
openssl pkcs12 -in server.pfx -nocerts -nodes -out private.key

the content of private.key is private key. 

6. import static catalog key pairs into keystore.jks (the keystore.jks is the value of ) 
Assume the name of the static catalog is mysql001, we get public key from keystoer001.jks (the alias must be the same as the name of static catalog) and encrypt the data. so we should import keystore001.jks into keystore.jks. 
you can use these command bellow:
keytool -v -importkeystore -srckeystore keystore001.jks -srcstoretype jks -srcstorepass openlookeng -destkeystore server.p12 -deststoretype pkcs12 -deststorepass openlookeng -destkeypass openlookeng
keytool -importkeystore -deststorepass openlookeng -destkeystore keystore.jks -srckeystore server.p12 -srcstoretype pkcs12 -srcstorepass openlookeng -alias mysql001

Case 2. Dynamic Catalog

A http request has the following shape (MySQL connector as an example):

request: POST/PUT
header: 'X-Presto-User: admin'
form: '
  • securityKey: The private key.
  • connection-password: The ciphertext encrypted with private key.
  • encrypted-properties: The encrypted property names.

Check dynamic catalog for more information.