有没有DMV告诉我当前数据库连接使用什么类型的证书

问题描述 投票:0回答:1

我需要知道外部签名、添加到 SQL 服务并提供给应用程序的证书是否实际被使用,因为 MS 有一个在旧支持版本中创建自签名 sha1 证书的坏习惯,而这些天这些证书被认为是不安全的。

我的目标是强制应用程序使用正确的证书并识别那些未使用适当证书的应用程序连接。

我查遍了互联网和DMV,但找不到信息。

sql-server certificate dmv
1个回答
0
投票

您无法在 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)";
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.