
鲲鹏安全库kunpengsecl API使用手册28个REST接口详细解析【免费下载链接】kunpengseclThis project develops security software components running on Kunpeng processors, specifically focusing on trusted computing related software components such as remote attestation client and service, etc.项目地址: https://gitcode.com/openeuler/kunpengsecl前往项目官网免费下载https://ar.openeuler.org/ar/鲲鹏安全库kunpengsecl是基于鲲鹏处理器的可信计算开源项目提供远程证明、密钥管理等核心安全功能。本文详细解析其28个REST接口的使用方法帮助开发者快速集成可信计算能力。一、API概览与基础信息1.1 API架构与功能定位鲲鹏安全库的REST API主要分为远程证明服务RAS和可信应用服务TAS两大模块覆盖设备管理、报告验证、基线配置等核心场景。接口设计遵循RESTful规范支持JSON/TEXT两种数据格式默认端口为5096。图1kunpengsecl远程证明服务架构图展示了API在可信计算流程中的位置1.2 快速上手环境准备git clone https://gitcode.com/openeuler/kunpengsecl cd kunpengsecl/attestation/ras go run cmd/main.go # 启动RAS服务基础URLhttp://localhost:5096认证方式支持HTTP Basic和OAuth2默认使用Basic认证账号密码在config.yaml中配置二、核心接口分类详解2.1 设备管理接口6个接口路径方法功能描述权限要求/GET获取所有服务器简要信息读权限/{id}GET获取指定服务器详情读权限/{id}POST修改服务器配置写权限/{id}DELETE删除服务器记录写权限/{from}/{to}GET分页查询服务器列表读权限/versionGET获取API版本信息读权限示例获取服务器列表curl -u admin:password http://localhost:5096/1/10返回示例[ {id:1,regtime:2023-01-01,trusted:true,online:true} ]2.2 报告管理接口6个用于查询和管理远程证明报告支持按服务器ID和报告ID筛选。关键接口包括/{id}/reports获取服务器所有证明报告/{id}/reports/{reportid}获取指定报告详情/{id}/reports/{reportid}删除指定报告报告数据结构定义于attestation/ras/restapi/api.gen.gotype ReportInfo struct { Id int64 json:id Createtime string json:createtime Validated bool json:validated Trusted bool json:trusted Quoted string json:quoted // TPM引用值 Signature string json:signature // 报告签名 }2.3 基线值管理接口8个基线值是判断设备可信状态的基准接口支持基线的增删改查图2基线值生成与更新流程展示了API在可信基线管理中的作用核心接口/{id}/basevalues获取服务器所有基线值/{id}/newbasevalue创建新基线值/{id}/basevalues/{basevalueid}修改指定基线值示例创建基线值curl -X POST -u admin:password http://localhost:5096/1/newbasevalue \ -d {name:BIOS基线,basetype:PCR,enabled:true}2.4 TA可信应用管理接口8个针对可信执行环境TEE中的应用提供报告和基线管理/{id}/ta/{tauuid}/tareports获取TA的证明报告/{id}/ta/{tauuid}/tabasevalues管理TA的基线值/{id}/ta/{tauuid}/status查询TA的信任状态TA信任状态枚举定义于attestation/ras/restapi/api.yamlTrustStatus: type: string enum: [unknown, untrusted, trusted]三、高级应用场景3.1 批量设备信任状态查询通过组合使用/{from}/{to}和/{id}/device/status接口实现大规模设备的信任状态巡检# 查询ID 1-100的设备信任状态 for i in {1..100}; do curl -s -u admin:password http://localhost:5096/$i/device/status done3.2 配置管理与动态更新通过/config接口管理服务配置支持运行时调整策略# 获取当前配置 curl -u admin:password http://localhost:5096/config # 更新配置开启自动基线更新 curl -X POST -u admin:password http://localhost:5096/config \ -d {isautoupdate:true}四、接口调用注意事项参数校验路径参数中的id需为整数tauuid需符合UUID格式权限控制写操作需write:servers权限在OAuth2中通过scope控制错误处理常见错误码包括401未授权、404资源不存在、400参数错误性能建议报告查询接口建议添加时间范围筛选避免全量数据返回五、接口文档与资源API定义文件attestation/ras/restapi/api.yaml数据模型attestation/ras/restapi/api.gen.go官方文档doc/KCMS_README.md通过本文档开发者可快速掌握kunpengsecl的REST API使用方法。如需进一步定制功能可参考源码中的ServerInterface接口实现自定义处理器。【免费下载链接】kunpengseclThis project develops security software components running on Kunpeng processors, specifically focusing on trusted computing related software components such as remote attestation client and service, etc.项目地址: https://gitcode.com/openeuler/kunpengsecl创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考