我正在尝试使用 ravendb 客户端连接到基于云的 ravendb 数据库。 我的本地计算机上没有任何问题,但是每当我尝试连接生产游戏服务器时,我都会收到以下错误:
禁止访问
{"Type":"InvalidAuth","Message":"This server requires client certificate for authentication, but none was provided by the client. Did you forget to install the certificate?"}
请注意,生产服务器在精简版本的 ubuntu Linux 上运行。
我验证了证书是随构建映像一起提供的。我已验证该证书有效且有效。我知道它可以正常工作,因为在我的本地环境中它可以正常工作。
我有以下代码:
public static class DocumentStoreHolder
{
private const string CERTIFICATE_PASSWORD = "-snip-";
private static string CERTIFICATE_PATH = Path.GetFullPath("certificate.pfx");
public static X509Certificate2 GetCertificate()
{
return new X509Certificate2(CERTIFICATE_PATH, CERTIFICATE_PASSWORD);
}
public static void Initialize()
{
var certificate = GetCertificate();
if (certificate.HasPrivateKey)
{
ksLog.Debug("Private key exists.");
}
else
{
ksLog.Debug("Private key does not exist.");
}
LazyStore = new Lazy<IDocumentStore>(() =>
{
var store = new DocumentStore
{
Urls = new[] { "-snip-" },
Database = "-snip-",
Certificate = certificate,
};
return store.Initialize();
});
}
private static Lazy<IDocumentStore> LazyStore;
public static IDocumentStore Store => LazyStore.Value;
}
生产服务器上输出“私钥存在”。所以我们知道证书已正确加载到内存中。
请注意,我使用的是.net Framework 4.8。我正在运行最新版本的 RavenDB 客户端。
我联系了支持人员,他们说了以下的话:
Basically it's about the X509 certificate's private key. In a lot of platform you need to allow the app to load that certificate explicitly e.g. by providing its thumbprint
不幸的是,这对我没有多大帮助。
如果其他人有建议或我可以尝试的事情,我将不胜感激..!
您的产品服务器和 RavenDB 云实例之间或之间是否有可能存在某种实用程序?
代码看起来不错,上次我看到这样的错误是在公司的安全团队启用软件过滤通过网络发送到服务器的客户端证书时。