如何在azure webjobs上管理SSL证书(x509certificate2)

编程入门 行业动态 更新时间:2024-10-18 20:25:12
本文介绍了如何在azure webjobs上管理SSL证书(x509certificate2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们正在开发一个需要与多个服务器通信的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)

本文发布于:2023-11-13 02:09:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583127.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:证书   如何在   azure   webjobs   SSL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!