Always Encrypted" column in SQL server

Mohammed Izzath 0 Reputation points
2024-07-27T14:31:40.0633333+00:00

I can't decrypt the "Always Encrypted" column in SQL server using the keys in azure key vault, I am using Go language for the process and I can't find any reference reagrding the decryption, please guide me to decrypt the data in SQL server, thank you.

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,799 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Erland Sommarskog 1.1L Reputation points MVP
    2024-07-29T21:53:19.7633333+00:00

    Since I don't know Go, and I don't think you generally can expect knowledge about Go and this specific driver here, I post an Answer with some advices for troubleshooting.

    1. First make sure that you can retrieve an unencrypted string column, using the same code. (To make sure that you are not doing some basic silly mistake.)
    2. Then run a query against an AE column for which the encryption is in your local certificate store. You can easily achieve this by using the AE wizard in SSMS. If this works, you know that the issue is the access to Azure Key Value. If it does not work, we can rule out AKV from the suspects.
    3. Also run the program with the local key from a different machine which does not have access to the encryption key, so that you understand what the behaviour is when the encryption key is not available.

    These steps may not lead to the answer, but you will be in better position to open an Issue on the Github site, if you first conduct your own troubleshooting.

    It occurs to me a little funny that you specify in the code all the details about AKV. I was under the impression that such information was stored in the database together with the key. But I have never used AE with Azure Key Vault. And certainly not from Go.

    1 person found this answer helpful.

  2. Bruce (SqlWork.com) 65,211 Reputation points
    2024-07-28T18:22:37.5633333+00:00

    Review the driver and samples

    https://github.com/microsoft/go-mssqldb


  3. LiHongMSFT-4306 27,016 Reputation points
    2024-07-29T02:26:34.67+00:00

    Hi @Mohammed Izzath

    Always Encrypted capabilities, including built-in column master key store providers vary by a driver library and its version.

    See Develop applications using Always Encrypted for the list of client drivers supporting Always Encrypted and for information on how to develop applications that query encrypted columns.

    You can also query encrypted columns using SQL tools, for example Azure Data Studio or SSMS.

    See this doc for more details: Always Encrypted.

    Best regards,

    Cosmog


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.