我们正在开发一个需要与多个服务器通信的Azure webjob,每个服务器都要求单独的SSL连接。我们将证书存储在外部服务器中,并在运行时加载相应的SSL连接设置。当我们调用X509Certificate2构造函数以将其添加到X509CertificateCollection时,webjob将以退出代码-1073740940停止并且其状态变为PendingRestart。我们的猜测是X509Certificate2类与webjobs不兼容,但是我们找不到任何关于如何解决这个问题的提示。
We are developing an Azure webjob that needs to communicate to several servers, each one of them demanding a separate SSL connection. We have our certificates stored in an external server and load them at runtime together with the corresponding SSL connection settings. When we invoke the X509Certificate2 constructor in order to add it to the X509CertificateCollection, the webjob gets stopped with exit code -1073740940 and its status becomes "PendingRestart". Our guess is that the X509Certificate2 class is not compatible with webjobs, but we cannot find any hint on how to tackle this issue.
private X509CertificateCollection GetClientCertificates(byte[] sslCertificateBytes) { log_?.OnEvent($"{nameof(SSLStreamFactory)} function {nameof(GetClientCertificates)} started"); X509CertificateCollection result = new X509Certificate2Collection(); log_?.OnEvent($"{nameof(X509CertificateCollection)} {nameof(result)} construction successfull"); try { if (sslCertificateBytes != null) { log_?.OnEvent($"{nameof(sslCertificateBytes)} enumerable != null"); result.Add(new X509Certificate2(sslCertificateBytes, socketSettings_.CertificatePassword)); log_?.OnEvent($"result.Add successful"); } else if (!string.IsNullOrEmpty(socketSettings_.CertificatePath)) { log_?.OnEvent($"{nameof(socketSettings_.CertificatePath)} != null"); result = new X509Certificate2Collection(); log_?.OnEvent($"{nameof(X509CertificateCollection)} {nameof(result)} construction successfull"); var clientCert = StreamFactory.LoadCertificate(socketSettings_.CertificatePath, socketSettings_.CertificatePassword, log_); log_?.OnEvent($"{nameof(StreamFactory.LoadCertificate)} function ended"); if (clientCert != null) { result.Add(clientCert); log_?.OnEvent($"result.Add successful"); } } } catch (Exception ex) { log_?.OnEvent($"{nameof(SSLStreamFactory)} function {nameof(GetClientCertificates)} raised exception: {ex.Message}"); throw; } log_?.OnEvent($"{nameof(SSLStreamFactory)} function {nameof(GetClientCertificates)} ended"); return result; }我的尝试: 我们正在互联网上寻找一个没有任何结果的答案。
What I have tried: We are looking for an answer in the internet without any result.
推荐答案{nameof(SSLStreamFactory)} function {nameof(GetClientCertificates)} started); X509CertificateCollection result = new X509Certificate2Collection(); log _?。OnEvent( "{nameof(SSLStreamFactory)} function {nameof(GetClientCertificates)} started"); X509CertificateCollection result = new X509Certificate2Collection(); log_?.OnEvent(
{nameof(X509CertificateCollection) } {nameof(result)} construction successfull); 尝试 { if (sslCertificateBytes!= null ) { log _?。OnEvent( "{nameof(X509CertificateCollection)} {nameof(result)} construction successfull"); try { if (sslCertificateBytes != null) { log_?.OnEvent(
{nameof(sslCertificateBytes)} enumerable!= null); result.Add( new X509Certificate2(sslCertificateBytes,socketSettings_.CertificatePassword)); log _?。OnEvent( "{nameof(sslCertificateBytes)} enumerable != null"); result.Add(new X509Certificate2(sslCertificateBytes, socketSettings_.CertificatePassword)); log_?.OnEvent(
更多推荐
如何在azure webjobs上管理SSL证书(x509certificate2)
发布评论