首页 > 应用开发 > 数据库开发技术 > Spring CredHub 2.0.1 是 Spring Cloud Services 项目中用于与 Pivotal CredHub(现为 VMware Tanzu CredHub)集成的客户端库版
Spring CredHub 2.0.1(发布于 2020 年初,对应 spring-cloud-services 2.0.x 系列)官方明确兼容 CredHub Server v2.2.x 至 v2.7.x,其 REST API 客户端基于 CredHub 的 v2 API 规范(即 /api/v2/* 路径),并针对该时期的服务端行为(如响应结构、错误格式、证书/凭据的 JSON schema)进行了适配。
✅ 已验证兼容版本(Pivotal/VMware 官方文档及集成测试覆盖):
value_type: json 的深层嵌套解析可能存在兼容性问题)❌ 不兼容或未测试/不推荐的版本:
version 字段语义变更(从整数序列号改为 UUID);/api/v2/data 接口废弃,统一为 /api/v2/credentials;permissions 字段与 RBAC 增强,导致旧客户端解析响应时可能抛 JsonMappingException;RestTemplate + HttpComponentsClientHttpRequestFactory 默认未适配新 TLS 栈;UaaTokenProvider 的 token 刷新逻辑。⚠️ 实际经验表明:在 v2.10+ 上强制使用 Spring CredHub 2.0.1 可能出现以下典型错误:
400 Bad Request:因请求体中 type 字段值(如 "password")被服务端拒绝(新版本要求小写且严格枚举);404 Not Found:调用已移除的 /api/v2/data 端点;Cannot construct instance of ...:Jackson 反序列化失败(因新增字段或字段类型变更);Invalid token:UAA 返回的 token scope 或 claims 结构变化,导致 UaaTokenProvider 解析失败。✅ 迁移建议:
spring-credhub 社区维护分支(如 io.pivotal.credhub:credhub-client:2.3.0.RELEASE) —— 注意:此库已脱离 Spring Cloud Services,由社区独立维护,API 向后兼容但需手动配置;com.cloudfoundry:credhub-client),其 v2.5.0+ 明确支持 CredHub Server v2.10+。Spring CredHub 2.0.1 是 Spring Cloud Services 项目中用于与 Pivotal CredHub(现为 VMware Tanzu CredHub)集成的客户端库版本,发布于2020年左右,主要面向 Spring Boot 应用提供对 CredHub 密钥管理服务的安全访问能力。该版本基于 Spring Framework 5.x 和 Spring Boot 2.x,支持 OAuth2 认证(通常通过 UAA)、TLS 客户端证书认证,以及对凭据(credentials)的 CRUD 操作(如 passwords、certificates、ssh keys、JSON 等类型)。
关键特性包括:
CredHubTemplate(类似 RestTemplate 的高层抽象);/myapp/db/password);@CredHubValue 注解(需配合 CredHubPropertySource)实现属性自动绑定;⚠️ 注意:Spring CredHub 项目已于 2022 年正式归档(EOL),不再维护;官方推荐迁移到通用方案如 Spring Cloud Vault、直接使用 CredHub REST API 或现代密钥管理服务(HashiCorp Vault、AWS Secrets Manager 等)。
Spring CredHub 2.0.1
Spring CredHub provides client-side support for storing, retrieving, and deleting credentials from a CredHub server running in a Cloud Foundry platform.
CredHub provides an API to securely store, generate, retrieve, and delete credentials of various types. Spring CredHub provides a Java binding for the CredHub API, making it easy to integrate Spring applications with CredHub.
Spring Boot Config
The recommended way to get started using Spring CredHub in your project is with a dependency management system. One of the snippets below can be copied and pasted into your build.
With Maven:
org.springframework.credhub spring-credhub-starter 2.0.0.RELEASEWith Gradle:
dependencies {
compile(‘org.springframework.credhub:spring-credhub-starter:2.0.0.RELEASE’)
}
Spring Initializr
Quickstart Your Project
Bootstrap your application with Spring Initializr.

原文作者:Bol5261;如有侵权,请联系管理员删除。