【Azure API 管理】在APIM中使用客户端证书验证API的请求,但是一直提示错误"No client certificate received."

简介: 【Azure API 管理】在APIM中使用客户端证书验证API的请求,但是一直提示错误"No client certificate received."

API 管理 (APIM) 是一种为现有后端服务创建一致且现代化的 API 网关的方法。

问题描述

在设置了APIM客户端证书,用户保护后端API,让请求更安全。 但是,最近发现使用客户端证书的API全部出现错误,无法收到客户端证书,通过浏览器中查看,发现证书也是无效的。

在API请求的Trace中,错误消息为:

{
                "source": "client-certificate-handler",
                "timestamp": "2021-07-13T12:23:51.8172847Z",
                "elapsed": "00:00:00.00053",
                "data": "Requesting client certificate because next handler requires access to it."
            }, {
                "source": "client-certificate-handler",
                "timestamp": "2021-07-13T12:23:51.8172847Z",
                "elapsed": "00:00:00.00048",
                "data": "No client certificate received."
            }

在浏览器中查看证书发现无效:

问题验证

根据消息提示,第一反应检查APIM的客户端证书是否有效,是否过期

 

第二步当证书并无异常(没有过期)时,则调查APIM是否有变动,通过配置的Git存储库(APIM Repository), Clone最新的文件后发现版本有变动。发现前后有版本变动 ( IntegrationModuleBitsVersion )

 

第三步:从APIM的证书设置入手,发现有新功能 ”协商客户端证书(Negotiate client certificate)“ 功能,在通过启用它之后,APIM的"No client certificate received" 问题消失

 

 

 

问题原因

因为在设置APIM时候,有一句提示消息为:”若要在开发人员层、基本层、标准层或高级层中通过 HTTP/2 接收和验证客户端证书,必须在“自定义域”边栏选项卡上启用“协商客户端证书”设置“” 。也就是说:如果不使用HTTP/2则不用启用"协商客户端证书"设置。这也是为什么在最初设置时,没有启用该功能的原因。

 

但是现在验证了问题的关键就是APIM升级后,必须启用"协商客户端证书", 通过对APIM的版本改动所发布的Release Notification(新版通知)看,是因为:

 

附录一:使用APIM Repository获取当前APIM中的所有文件,包含根目录的configuration.json文件

第一步:在APIM中启用Repository

第二步:通过 git clone https://username:password@{name}.scm.azure-api.cn/  下载APIM所有文件到本地

 

详细操作步骤:https://docs.azure.cn/zh-cn/api-management/api-management-configuration-repository-git#to-clone-the-repository-to-your-local-machine

 

 

第三步:查看configuration.json文件 IntegrationModuleBitsVersion 信息

{
  "settings": {
    "RegistrationEnabled": "True",
    "UserRegistrationTerms": null,
    "UserRegistrationTermsEnabled": "False",
    "UserRegistrationTermsConsentRequired": "False",
    "DelegationEnabled": "False",
    "DelegationUrl": "",
    "DelegatedSubscriptionEnabled": "False"
  },
  "$ref-policy": "api-management/policies/global.xml",
  "IntegrationModuleVersion": "17",
  "IntegrationModuleBitsVersion": "0.20.1220.0",
  "ExportDate": "2021-06-09T22:08:15.530921Z"
}

 

参考文档

将存储库克隆到本地计算机:https://docs.azure.cn/zh-cn/api-management/api-management-configuration-repository-git#to-clone-the-repository-to-your-local-machine

如何使用 API 管理中的客户端证书身份验证确保 API 安全:https://docs.azure.cn/zh-cn/api-management/api-management-howto-mutual-certificates-for-clients

APIM Release: https://github.com/Azure/API-Management/releases/tag/release-service-2021-05

A regular Azure API Management service update was started on May 5, 2021, and included the following new features, bug fixes, and other improvements. It may take several weeks for your API Management service to receive the update.

Featured

  1. Open-source API Portal is now generally available.
  2. Azure API Management's support for Availability Zones is now generally available.
  3. Request and response validation policies are now generally available.

New

  1. You can now validate the client certificate with the new <validate-client-certificate> policy. Documentation and support in the Azure portal are coming soon.
  2. The Visual Studio Code extension now supports policy debugging for self-hosted gateways running locally.
  3. The Visual Studio Code extension now supports Dapr and validation policies.
  4. The developer portal now supports resource owner password grant flow.
  5. The new Ciphers + Protocols page in the Azure portal lets you manage API gateways' cipher and protocol configuration and displays a warning if a weak cipher or protocol is enabled.
  6. The Locations page in the Azure portal lets you now configure Availability Zones.
  7. You can now apply validation policies with the visual policy editors in the Azure portal, without writing any policy code.
  8. The timeout attribute of the send-request policy now supports policy expressions.

Fixed

  1. Caching issues, which might have resulted in a broken developer portal's administrative interface, are now resolved.

Changed

  1. The client certificate renegotiation feature is now disabled for all new and existing API Management services, except for the services that relied on it in the last 30 days (services with at least one API call that resulted in a client certificate request from a policy, not as part of an initial TLS handshake). The API gateway will request a client certificate only if HostnameConfiguration's property negotiateClientCertificate is set to true. If the property is set to false, the client certificate won't be available in the context.Request.Certificate property.

 

【END】

相关文章
|
3天前
|
JSON 前端开发 API
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
24 5
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
|
2月前
|
JavaScript API C#
【Azure Developer】Python代码调用Graph API将外部用户添加到组,结果无效,也无错误信息
根据Graph API文档,在单个请求中将多个成员添加到组时,Python代码示例中的`members@odata.bind`被错误写为`members@odata_bind`,导致用户未成功添加。
50 10
|
2月前
|
API Python
【Azure Developer】分享一段Python代码调用Graph API创建用户的示例
分享一段Python代码调用Graph API创建用户的示例
68 11
|
2月前
|
JSON API 数据格式
获取商品详情API的请求格式是什么
获取商品详情API的请求格式通常依赖于特定的电商平台或服务提供商,但一般遵循类似的结构。以下是一个概括性的说明,以及针对几个主流电商平台的示例:
|
3月前
|
存储 数据可视化 API
重磅干货,免费三方网络验证[用户系统+CDK]全套API接口分享教程。
本套网络验证系统提供全面的API接口,支持用户注册、登录、数据查询与修改、留言板管理等功能,适用于不想自建用户系统的APP开发者。系统还包含CDK管理功能,如生成、使用、查询和删除CDK等。支持高自定义性,包括20个自定义字段,满足不同需求。详细接口参数及示例请参考官方文档。
|
4月前
|
缓存 监控 API
抖音抖店 API 请求获取宝贝详情数据的调用频率限制如何调整?
抖音抖店API请求获取宝贝详情数据的调用频率受限,需遵循平台规则。开发者可通过提升账号等级、申请更高配额、优化业务逻辑(如缓存数据、异步处理、批量请求)及监控调整等方式来应对。
|
3月前
|
JSON API 数据格式
携程API接口系列,酒店景点详情请求示例参考
携程API接口系列涵盖了酒店预订、机票预订、旅游度假产品预订、景点门票预订等多个领域,其中酒店和景点详情请求是较为常用的功能。以下提供酒店和景点详情请求的示例参考
|
5天前
|
API PHP 开发者
速卖通商品详情接口(速卖通API系列)
速卖通(AliExpress)是阿里巴巴旗下的跨境电商平台,提供丰富的商品数据。通过速卖通开放平台(AliExpress Open API),开发者可获取商品详情、订单管理等数据。主要功能包括商品搜索、商品详情、订单管理和数据报告。商品详情接口aliexpress.affiliate.productdetail.get用于获取商品标题、价格、图片等详细信息。开发者需注册账号并创建应用以获取App Key和App Secret,使用PHP等语言调用API。该接口支持多种请求参数和返回字段,方便集成到各类电商应用中。
|
11天前
|
JSON API 数据格式
微店商品列表接口(微店 API 系列)
微店商品列表接口是微店API系列的一部分,帮助开发者获取店铺中的商品信息。首先需注册微店开发者账号并完成实名认证,选择合适的开发工具如PyCharm或VS Code,并确保熟悉HTTP协议和JSON格式。该接口支持GET/POST请求,主要参数包括店铺ID、页码、每页数量和商品状态等。响应数据为JSON格式,包含商品详细信息及状态码。Python示例代码展示了如何调用此接口。应用场景包括商品管理系统集成、数据分析、多平台数据同步及商品展示推广。
|
2天前
|
监控 供应链 搜索推荐
亚马逊商品详情接口(亚马逊 API 系列)
亚马逊作为全球最大的电商平台之一,提供了丰富的商品资源。开发者和电商从业者可通过亚马逊商品详情接口获取商品的描述、价格、评论、排名等数据,对市场分析、竞品研究、价格监控及业务优化具有重要价值。接口基于MWS服务,支持HTTP/HTTPS协议,需注册并获得API权限。Python示例展示了如何使用mws库调用接口获取商品详情。应用场景包括价格监控、市场调研、智能选品、用户推荐和库存管理等,助力电商运营和决策。
44 23

热门文章

最新文章