尝试打开远程证书存储时获取 "The network path was not found"
Getting "The network path was not found" when trying to open remote cert store
我正在尝试从远程计算机的证书存储中获取未过期证书的列表。对于某些机器,这工作正常,但对于其他机器,我收到以下错误:
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The network path was not found.
at Internal.Cryptography.Pal.StorePal.FromSystemStore(String storeName, StoreLocation storeLocation, OpenFlags openFlags)
at System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags)
at GetCertificates(String server)
这是来自的代码片段:
var store = new X509Store($@"\{server}\My", StoreLocation.LocalMachine);
var certList = new List<X509Certificate2>();
try
{
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
certList = store.Certificates.Cast<X509Certificate2>()
.Where(x => x.NotBefore < DateTime.Now &&
DateTime.Now < x.NotAfter).ToList();
}
catch (Exception e)
{
throw;
}
finally
{
store.Close();
}
知道为什么某些机器可能会发生这种情况 and/or 可能 workarounds/solutions 吗?
谢谢
根据给出的异常,这是由于不正确或有效的网络路径。检查您是否可以从托管上述代码的服务器访问远程服务器。
找到解决办法。我 运行 我的应用程序作为管理员 现在它似乎能够解析网络路径。我猜我们对这些服务器进行了一些 configuration/permission 设置,只允许 'admins' 远程访问证书。
我正在尝试从远程计算机的证书存储中获取未过期证书的列表。对于某些机器,这工作正常,但对于其他机器,我收到以下错误:
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The network path was not found.
at Internal.Cryptography.Pal.StorePal.FromSystemStore(String storeName, StoreLocation storeLocation, OpenFlags openFlags)
at System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags)
at GetCertificates(String server)
这是来自的代码片段:
var store = new X509Store($@"\{server}\My", StoreLocation.LocalMachine);
var certList = new List<X509Certificate2>();
try
{
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
certList = store.Certificates.Cast<X509Certificate2>()
.Where(x => x.NotBefore < DateTime.Now &&
DateTime.Now < x.NotAfter).ToList();
}
catch (Exception e)
{
throw;
}
finally
{
store.Close();
}
知道为什么某些机器可能会发生这种情况 and/or 可能 workarounds/solutions 吗?
谢谢
根据给出的异常,这是由于不正确或有效的网络路径。检查您是否可以从托管上述代码的服务器访问远程服务器。
找到解决办法。我 运行 我的应用程序作为管理员 现在它似乎能够解析网络路径。我猜我们对这些服务器进行了一些 configuration/permission 设置,只允许 'admins' 远程访问证书。