Always-Encrypted MSSQL Server w/ Azure Key Vault

Our CFML Server is hosted by Viviotech.
In another location, a Microsoft SQL Server on the Azure cloud.

Because the database stores HIPAA protected information, we need to apply the “Always-Encrypted” setting to the Database and encrypt certain columns in certain tables.

MY QUESTION:
Has anyone configured a datasource in Lucee - to 1) employ an “Always-Encrypted” MS DB where 2) the key is located on Azure Key Vault?

On CF2018, this is the error we get when I add mssql-jdbc-9.2.1.jre11.jar and try to configure ColdFusion’s “Other” DSN via their UI and custom connection strings.

Invalid key store provider name: AZURE_KEY_VAULT. A key store provider name must denote either a system key store provider or a registered custom key store provider. Valid system key provider names are: ,[MSSQL_CERTIFICATE_STORE]. Valid (currently registered) custom key store provider names are: null. Please verify key store provider information in column master key definitions in the database, and verify all custom key store providers used in your application are registered properly.

We’ve configured a NON-COLDFUSION client to connect and decrypt data from this server successfully, so it doesn’t seem to be a permissions issue there (the first thing we fixed)

I’ve been telling this client about Lucee (which I use elsewhere) for years. I was just told by Adobe support that Always-Encrypted feature is not supported in CF2018, so this is a good time to pounce!

Maybe this will help?

Where are you storing your keys? Azure, Cert Store, Java?

Thanks @kabutotx

In this setup, the MSSQL DB is on Azure, and the key is also in the Azure Key Vault. The CFML Engine is over at Viviotech.

Yes, I have read this - and many other pages on the general “Always Encrypted” topic. There are solutions on SO and at Hostek, but they seem to assume the key is local, which is not the case here. The driver needs to go fetch it. Actually, I can get the key as a string from the vault using cfttp, but don’t know what to do with it once I have it.

My confusion comes from all the suggestions about “customizing” a JDBC driver as may be needed, while both ColdFusion and Lucee only provide a relatively simple place (a form) to set some parameters. Some of these properties cannot be represented in a connection string, or set anywhere in the Administrator.

So, some customization is apparently needed, I just don’t know WHERE to put it.
A text configuration file somewhere?
Throw a bunch of Java invocations into the Application’s startup event?
Rewrite every DB tag to use a custom object?

If you you use the Azure Vault it says you need the azure-security-keyvault-keys and azure-identity dependencies. You can get those jars from the maven repository. Then put in the connection string settings you need for the driver version and if using 8.4.1 or greater if you are using managed identity.

Examples with just key and id
8.4.1+
…;columnEncryptionSetting=Enabled;keyStoreAuthentication=KeyVaultClientSecret;keyStorePrincipalId=clientId;keyStoreSecret=clientSecret

7.4.1
…;columnEncryptionSetting=Enabled;keyVaultProviderClientId=ClientId;keyVaultProviderClientKey=ClientKey

The topic is a bit more complex and I suffered too before writing this article: Full Tutorial on using Always Encrypted with Azure Key Vault in ASP.NET and ASP.NET Core - CodeProject
Hopefully, from now on, this topic will become less of a pain :slight_smile:

1 Like

What maven repository? Where?

Wow 2 years ago.

https://mvnrepository.com/

Search for the names I listed above. Click on that repository and then select a version. You should see JAR files under Files section for that version. I don’t know how Viviotech has Lucee setup, so I don’t know where you need to put them for Lucee to see them (WEB-INF\lib maybe?). Contact Viviotech on that.

1 Like

Hi @kabutotx ,

I’m trying to setup a datasource with Azure Key Vault and have included the 2 JAR files mentioned in /opt/lucee/server/lucee-server/context/lib/, but get the below error when verifying the connection:

java.lang.NoClassDefFoundError: com/microsoft/aad/msal4j/IClientCredential … 81 more Caused by: java.lang.ClassNotFoundException: com.microsoft.aad.msal4j.IClientCredential not found by org.lucee.mssql [60]

Are there other required JARs I need to include?

Thank you.

You can get it from Maven.
Maven Repository: com.microsoft.azure » msal4j