add-ca-truststore/README.md

1.0 KiB

Add root certificate to java truststore

Github action to add a root certificate in x509 format to an existing java truststore.

usage example

name: Main

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: runner
    steps:
      - name: Retrieve root ca certificate
        id: get-ca-cert
        uses: https://antoine-roux.tk/projects/actions/get-ca-cert@v1.1.0

      - run: |
          echo "${{ steps.get-ca-cert.outputs.ca-cert }}"          

      - uses: actions/setup-java@v4
        id: java
        with:
          distribution: 'temurin'
          java-version: '21'

      - name: Add root certificate to java truststore
        uses: https://antoine-roux.tk/projects/actions/add-ca-truststore@v1.2.0
        id: add-ca-to-truststore
        with:
          ca-cert: "${{ steps.get-ca-cert.outputs.ca-cert }}"
          store-path: "${{ steps.java.outputs.path }}/lib/security/cacerts"

      - run: |
          echo "Auto generated alias name: ${{ steps.add-ca-to-truststore.outputs.certificate-alias }}"
          keytool -list -cacerts