使用带有 Azure AD 应用程序注册的客户端证书从控制台应用程序调用 Azure 服务总线时的身份验证流程是什么

What is the authentication flow when calling Azure Service Bus from console app using Client Certificate with Azure AD App Registration

我使用 C# 创建了一个调用 Azure 服务总线发送消息的控制台应用程序,在 Azure AD 中设置了一个应用程序注册设置,并使用客户端证书作为身份验证。

为此我使用天蓝色的“ClientCertificateCredential”class。

这有效。

但是,我不确定它的流程以及它是如何工作的。它在幕后做什么?它如何将该证书添加到请求中?它与 TLS 证书有什么不同?是不是只有1个电话?还是通过发出 1 个请求,然后返回一个令牌,再发出另一个请求来做任何事情?等等

我还没找到流程图。

这里是测试代码供参考:

string tenantId = "xxx";
string clientId = "xxx";
string clientCertPath = "mykey.pem";
string queueName = "xxx";
string fullyQualifiedNamespace = "xxx.servicebus.windows.net";

TokenCredential credential = new ClientCertificateCredential(tenantId, clientId, clientCertPath);
var client = new ServiceBusClient(fullyQualifiedNamespace, credential);

ServiceBusSender sender = client.CreateSender(queueName);

ServiceBusMessage busMessage = new ServiceBusMessage("test");

sender.SendMessageAsync(busMessage).Wait();

Client Certificate Authentication是一种基于相互证书的身份验证,其中客户端向服务器提供其客户端证书以证明其身份。这是作为 SSL 握手

的一部分发生的

ClientCertificateCredential Class 使用分配给应用程序注册的客户端证书启用服务主体(应用程序注册)到 Azure Active Directory 的身份验证

TokenCredential Class从提供的ClientCertificateCredential中获取访问令牌

此访问令牌将用于访问 Azure 服务总线

关于客户端证书认证的更多信息,您可以参考这篇博客:Client Certificate Authentication - Microsoft Tech Community