I've read plenty about asymmetric keys and certificates in SQL Server (2012) but those seem to be specifically for signing data. What I have is a SQL CLR assembly that I have signed with a digital certificate and have successfully loaded as an UNSAFE assembly and executed the SqlFunction successfully as well. However, I want to add logic to the SqlFunction to verify the assembly was signed by my cert. For all other assemblies we extract the public key and compare it to a key in the license file. But there seems to be no way to extract the public key when the assembly is executing inside of SQL. Is there some piece of this SQL CLR or CERT/ASK architecture that I am not understanding in order to get access to this? TIA!
Clarification of Need:
We sell software that generates data in binary format into our database schema, therefore a customer cannot easily query the data directly using T-SQL. This is done both for performance and to black-box our data analysis algorithms that output the data. Currently customers must use our software to "unpack" this blob data via "BusnLogicCore.dll". This dll will only execute if the calling assembly has been signed by a certificate that we have approved in advance. For customers who purchase our SDK, the customer sends us the public key of their own cert. and we add the pk to the license file we issue to them, so that assembly can confirm that they are allowed to call BusnLogicCore.dll. We're now creating SQL CLR function that would allow a customer to use T-SQL to call BusnLogicCore.dll and unpack the blob data as part of their query. However, we have been unable to confirm that the SQL CLR function has been signed by a certificate that we have approved to call BusnLogicCore.dll. If we poke a hole in this logic to have an exception such that SQL CLR functions don't have to go through this verification, then a customer who has not purchased the SDK can write their own SQL CLR function to call BusnLogicCore.dll. It is a tad more complicated than that, and there are additional checks we can do on the license, but it would be preferable not to have to bypass this verification. Is this an edge case? Probably, but we want to protect our IP as best we can, and not having this option is frustrating.
Update: I have checked the sys.certificates table, but neither the cert_serial_number, nor the thumbprint columns match the public key of the cert.