我需要知道外部签名、添加到 SQL 服务并提供给应用程序的证书是否实际被使用,因为 MS 有一个在旧支持版本中创建自签名 sha1 证书的坏习惯,而这些天这些证书被认为是不安全的。
我的目标是强制应用程序使用正确的证书并识别那些未使用适当证书的应用程序连接。
我查遍了互联网和DMV,但找不到信息。
您无法在 TSQL 中获取它,只能从注册表中获取。
您可以使用 Powershell:
$instancename = YourInstanceHere;
$thumprint = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instancename\MSSQLServer\SuperSocketNetLib" -Name Certificate;
if ($thumprint -eq $null)
{
"No certificate set";
}
else
{
$cert = (dir -Path cert:\$thumprint -Recurse)[0];
if ($cert -eq $null)
{
"No certificate found";
else
{
"Is Self Signed $($cert.Subject -eq $cert.Issuer)";
}
}