【问题标题】:Custom certificate for Spring Boot build packSpring Boot 构建包的自定义证书
【发布时间】:2021-07-12 19:26:03
【问题描述】:

我正在尝试为使用构建包(使用默认 Packeto 设置和 Spring Boot 2.5)打包的 Spring Boot 应用程序包含自定义证书颁发机构。根据docs,我可以通过创建ca-certificates 类型的新绑定并包含原始PEM 文件,在我的映像中包含自定义证书。

但不清楚在我的项目中的何处 包含这些工件,或者是否有任何特殊的命名约定要遵循以便pack 命令获取我的绑定。我有一个典型的带有 Maven 的 Spring Boot 布局,并且基于 sample project 我已经尝试过这个布局:

它只是我项目顶层名为binding 的目录,其中包含type 文件和我的CA。 type 文件是来自示例项目的复制/粘贴,仅包含文本 ca-certificate

但我的证书没有包含在最终的 Docker 映像中。我也试过将此目录移动到src/main 区域内,但没有成功。

将自定义 CA 包含在我的映像中的正确设置是什么?

【问题讨论】:

    标签: spring-boot buildpack


    【解决方案1】:

    我认为 Spring Boot Maven 插件会知道在哪里寻找新绑定的假设是不正确的。从 Spring Boot 2.5 开始,您现在可以将绑定信息作为插件配置的一部分传递:

                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <image>
                            <bindings>
                                <binding>${project.basedir}/platform/bindings:/platform/bindings</binding>
                            </bindings>
                        </image>
    

    因此,您可以将绑定目录(类型文件 + CA 证书文件)保存在您想要的任何位置,您只需告诉插件它们存在的位置,以便可以将其传递给 pack 命令。完成此操作后,我看到在构建过程中添加了我的证书:

    [INFO]     [creator]     Paketo CA Certificates Buildpack 2.3.2
    [INFO]     [creator]       https://github.com/paketo-buildpacks/ca-certificates
    [INFO]     [creator]       Launch Helper: Reusing cached layer
    [INFO]     [creator]       CA Certificates: Contributing to layer
    [INFO]     [creator]         Added 1 additional CA certificate(s) to system truststore
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-30
      • 2020-12-05
      • 1970-01-01
      • 2021-03-17
      • 1970-01-01
      相关资源
      最近更新 更多