%3CLINGO-SUB%20id%3D%22lingo-sub-1872461%22%20slang%3D%22en-US%22%3EAlways%20Encrypted%20Data%20Displayed%20in%20SSRS%20with%20a%20gMSA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1872461%22%20slang%3D%22en-US%22%3E%3CP%3ELet's%20take%20a%20look%20at%20how%20to%20display%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsecurity%2Fencryption%2Falways-encrypted-database-engine%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAlways%20Encrypted%3C%2FA%3E%20Data%20in%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Freporting-services%2Fcreate-deploy-and-manage-mobile-and-paginated-reports%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESSRS%3C%2FA%3E%20with%20a%20gMSA%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows-server%2Fsecurity%2Fgroup-managed-service-accounts%2Fgroup-managed-service-accounts-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGroup%20Managed%20Service%20Account%3C%2FA%3E).%20We%20are%20mixing%20some%20technologies%20and%20the%20one%20that%20throws%20a%20wrench%20into%20things%20is%20the%20gMSA.%20Here%20is%20the%20flow%20for%20moving%20the%20certificates.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ryanjadams_0-1605022921759.jpeg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F232637i9FCB8BC32E27A404%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ryanjadams_0-1605022921759.jpeg%22%20alt%3D%22ryanjadams_0-1605022921759.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlways%20Encrypted%20protects%20our%20data%20both%20at%20rest%20and%20in%20transit.%20To%20accomplish%20that%2C%20SQL%20only%20stores%20the%20encrypted%20data%20and%20cannot%20decrypt%20it%3B%20all%20the%20work%20is%20done%20by%20the%20client.%20In%20our%20case%20the%20client%20is%20SSRS%20and%20it%20is%20the%20account%20running%20the%20SSRS%20service%20that%20will%20need%20the%20certificate%20to%20decrypt%20data.%20Note%20that%20it%20is%20not%20the%20account%20running%20the%20report.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ECertificate%20Stores%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWhen%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsecurity%2Fencryption%2Falways-encrypted-database-engine%3Fview%3Dsql-server-ver15%23configuring-always-encrypted%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Econfiguring%20Always%20Encrypted%3C%2FA%3E%2C%20we%20have%20a%20choice%20between%20two%20key%20stores.%20In%20our%20example%20we%20will%20use%20the%20Windows%20Certificate%20Store.%20You%20can%20also%20use%20Azure%20Key%20Vault%2C%20but%20direct%20access%20with%20that%20method%20is%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpower-bi%2Freport-server%2Falways-encrypted-support%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Enot%20supported%20with%20SSRS%3C%2FA%3E.%20You%20could%20use%20the%20Windows%20Certificate%20Store%2C%20export%20the%20certificate%2C%20and%20import%20it%20into%20Azure%20Key%20Vault.%20However%2C%20SSRS%20cannot%20directly%20access%20Azure%20Key%20Vault.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20certificate%20is%20important%20because%20we%20must%20export%20it%20so%20we%20can%20later%20import%20it%20to%20our%20clients.%20Best%20practice%20is%20to%20run%20the%20Encrypt%20Column%20Wizard%20in%20SSMS%20from%20a%20server%20that%20is%20not%20the%20server%20hosting%20your%20data.%20This%20prevents%20us%20from%20accidentally%20leaving%20the%20cert%20on%20the%20server%20where%20if%20it%20gets%20compromised%20the%20attacker%20could%20get%20both%20the%20data%20and%20the%20certificate.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAlways%20Encrypted%20Wizard%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIf%20you%20run%20the%20wizard%20from%20the%20client%20or%20application%20server%2C%20you%20have%20two%20choices.%20The%20first%20is%20to%20run%20SSMS%20as%20an%20administrator%20so%20you%20can%20store%20the%20certificate%20in%20the%20local%20machine%20store.%20This%20allows%20any%20application%20on%20the%20server%20to%20use%20the%20certificate%20if%20you%20give%20it%20permissions%20to%20do%20so.%20If%20you%20do%20not%20run%20SSMS%20as%20an%20administrator%2C%20you%20will%20only%20see%20the%20option%20to%20store%20the%20certificate%20in%20the%20local%20user%20store%20for%20the%20current%20user.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ryanjadams_1-1605022921762.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F232636i93F7B50BF3706312%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ryanjadams_1-1605022921762.png%22%20alt%3D%22ryanjadams_1-1605022921762.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20our%20example%20we%20will%20use%20the%20Current%20User%20store%20to%20comply%20with%20the%20principal%20of%20%22%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FPrinciple_of_least_privilege%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELeast%20User%20Privilege%3C%2FA%3E%22.%20Once%20we%20complete%20the%20Always%20Encrypted%20wizard%2C%20you%20can%20open%20Certificate%20Manager%20and%20export%20the%20cert%20making%20sure%20to%20include%20the%20private%20key.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ryanjadams_2-1605022921770.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F232638iD1C12C1140AA3725%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ryanjadams_2-1605022921770.png%22%20alt%3D%22ryanjadams_2-1605022921770.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ryanjadams_3-1605022921771.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F232640i5963E7D0F4946BBD%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ryanjadams_3-1605022921771.png%22%20alt%3D%22ryanjadams_3-1605022921771.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAlways%20Encrypted%20Certificate%20Import%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWe%20have%20our%20column%20encrypted%20and%20have%20exported%20the%20certificate.%20Next%2C%20we%20need%20to%20import%20it%20on%20the%20SSRS%20server.%20This%20is%20where%20the%20fun%20begins.%20You%20might%20be%20tempted%20to%20just%20import%20the%20certificate%20into%20the%20local%20machine%20store%20instead%20of%20the%20user%20store%20so%20all%20applications%20can%20use%20it.%20This%20does%20not%20work%2C%20and%20you%20will%20have%20to%20import%20into%20the%20user%20store%20for%20the%20account%20running%20the%20SSRS%20service.%20Normally%20you%20could%20right%20click%20the%20certificate%20manager%20and%20select%20%22Run%20As%22%20to%20be%20in%20the%20context%20of%20the%20account%20running%20SSRS.%20This%20does%20not%20work%20with%20a%20gMSA%20because%20you%20don't%20know%20the%20password.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet%20Creative%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIt's%20time%20to%20get%20creative%20and%20break%20out%20some%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsysinternals%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESysInternals%3C%2FA%3E%20tools.%20We%20are%20going%20to%20use%20PSExec%20to%20open%20Certificate%20Manager%20under%20the%20credentials%20of%20our%20SSRS%20gMSA%20account.%20We%20start%20by%20opening%20an%20administrative%20command%20prompt%20and%20executing%20the%20following%20from%20the%20location%20where%20we%20downloaded%20the%20SysInternals%20tools.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ryanjadams_4-1605022921772.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F232639i4B636CD1D2F309E2%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ryanjadams_4-1605022921772.png%22%20alt%3D%22ryanjadams_4-1605022921772.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20parameter%20-i%20is%20needed%20since%20we%20will%20be%20launching%20another%20command%20prompt%20interactively%20on%20the%20desktop.%20The%20second%20parameter%20-u%20provides%20our%20username%20and%2C%20in%20our%20case%2C%20the%20gMSA%20running%20the%20SSRS%20service.%20Remember%20that%20gMSA%20accounts%20need%20a%20%24%20sign%20at%20the%20end.%20The%20third%20parameter%20-p%20is%20the%20password%20for%20the%20gMSA%20account%2C%20but%20we%20do%20not%20know%20what%20it%20is.%20The%20~%20is%20allowed%20in%20place%20of%20the%20password.%20The%20last%20thing%20we%20provide%20is%20the%20executable%20we%20want%20to%20run.%20For%20us%20it%20will%20be%20another%20command%20prompt.%20Ideally%2C%20we%20would%20like%20to%20just%20run%20certmgr.exe%20from%20here%2C%20but%20that%20does%20not%20work.%3C%2FP%3E%0A%3CP%3EOnce%20you%20hit%20enter%20another%20command%20prompt%20will%20open%20where%20we%20can%20enter%20certmgr.exe%20to%20open%20the%20Certificate%20Manager%20under%20the%20context%20of%20our%20gMSA%20account.%20Now%20we%20can%20finally%20import%20the%20certificate.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ryanjadams_5-1605022921774.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F232641iC064EB2E31D69AAD%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ryanjadams_5-1605022921774.png%22%20alt%3D%22ryanjadams_5-1605022921774.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ryanjadams_6-1605022921776.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F232642i08449A730B570ADE%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ryanjadams_6-1605022921776.png%22%20alt%3D%22ryanjadams_6-1605022921776.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EView%20Your%20Reports%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThat's%20it!%20Now%20you%20can%20go%20open%20your%20report%20in%20SSRS%20and%20see%20your%20Always%20Encrypted%20data%20displayed.%20These%20are%20some%20great%20security%20technologies%2C%20but%20it%20takes%20some%20outside%20of%20the%20box%20ideas%20to%20get%20them%20working%20together%20correctly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1872461%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20display%20Always%20Encrypted%20Data%20in%20SQL%20Reporting%20Services%20using%20Group%20Managed%20Service%20Accounts%20for%20the%20SSRS%20service.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1872461%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ERyanAdams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Let's take a look at how to display Always Encrypted Data in SSRS with a gMSA (Group Managed Service Account). We are mixing some technologies and the one that throws a wrench into things is the gMSA. Here is the flow for moving the certificates.

 

ryanjadams_0-1605022921759.jpeg

 

 

Always Encrypted protects our data both at rest and in transit. To accomplish that, SQL only stores the encrypted data and cannot decrypt it; all the work is done by the client. In our case the client is SSRS and it is the account running the SSRS service that will need the certificate to decrypt data. Note that it is not the account running the report.

 

Certificate Stores

When configuring Always Encrypted, we have a choice between two key stores. In our example we will use the Windows Certificate Store. You can also use Azure Key Vault, but direct access with that method is not supported with SSRS. You could use the Windows Certificate Store, export the certificate, and import it into Azure Key Vault. However, SSRS cannot directly access Azure Key Vault.

 

The certificate is important because we must export it so we can later import it to our clients. Best practice is to run the Encrypt Column Wizard in SSMS from a server that is not the server hosting your data. This prevents us from accidentally leaving the cert on the server where if it gets compromised the attacker could get both the data and the certificate.

 

Always Encrypted Wizard

If you run the wizard from the client or application server, you have two choices. The first is to run SSMS as an administrator so you can store the certificate in the local machine store. This allows any application on the server to use the certificate if you give it permissions to do so. If you do not run SSMS as an administrator, you will only see the option to store the certificate in the local user store for the current user.

 

ryanjadams_1-1605022921762.png

 

 

For our example we will use the Current User store to comply with the principal of "Least User Privilege". Once we complete the Always Encrypted wizard, you can open Certificate Manager and export the cert making sure to include the private key.

 

ryanjadams_2-1605022921770.png

 

 

ryanjadams_3-1605022921771.png

 

 

Always Encrypted Certificate Import

We have our column encrypted and have exported the certificate. Next, we need to import it on the SSRS server. This is where the fun begins. You might be tempted to just import the certificate into the local machine store instead of the user store so all applications can use it. This does not work, and you will have to import into the user store for the account running the SSRS service. Normally you could right click the certificate manager and select "Run As" to be in the context of the account running SSRS. This does not work with a gMSA because you don't know the password.

 

Get Creative

It's time to get creative and break out some SysInternals tools. We are going to use PSExec to open Certificate Manager under the credentials of our SSRS gMSA account. We start by opening an administrative command prompt and executing the following from the location where we downloaded the SysInternals tools.

 

ryanjadams_4-1605022921772.png

 

The first parameter -i is needed since we will be launching another command prompt interactively on the desktop. The second parameter -u provides our username and, in our case, the gMSA running the SSRS service. Remember that gMSA accounts need a $ sign at the end. The third parameter -p is the password for the gMSA account, but we do not know what it is. The ~ is allowed in place of the password. The last thing we provide is the executable we want to run. For us it will be another command prompt. Ideally, we would like to just run certmgr.exe from here, but that does not work.

Once you hit enter another command prompt will open where we can enter certmgr.exe to open the Certificate Manager under the context of our gMSA account. Now we can finally import the certificate.

 

ryanjadams_5-1605022921774.png

 

 

ryanjadams_6-1605022921776.png

 

 

View Your Reports

That's it! Now you can go open your report in SSRS and see your Always Encrypted data displayed. These are some great security technologies, but it takes some outside of the box ideas to get them working together correctly.