25 Commits

Author SHA1 Message Date
Christian Tosta
e82c47bd49 Updated Fedora build CI
Some checks failed
Build and Release CI / release-ci (push) Has been cancelled
Build and Release CI / build-fedora (push) Has been cancelled
2025-04-18 14:49:45 -03:00
Christian Tosta
52b949232f Updated Fedora build CI 2025-04-18 14:44:33 -03:00
Christian Tosta
39ebc58474 Updated Fedora build CI 2025-04-18 14:36:56 -03:00
Christian Tosta
582cc027e8 Updated Fedora build CI 2025-04-18 14:34:38 -03:00
Christian Tosta
4eb3f5c61a Updated Fedora build CI 2025-04-18 14:23:42 -03:00
Christian Tosta
34d45a47d2 Updated Fedora build CI 2025-04-18 14:23:27 -03:00
Christian Tosta
94912593f0 Added Fedora build CI 2025-04-18 13:37:13 -03:00
Christian Tosta
bfe09d01e9 Added Fedora build CI 2025-04-18 13:31:40 -03:00
Christian Tosta
adca4dcde3 Added Fedora build CI 2025-04-18 13:29:47 -03:00
Christian Tosta
6fb0bf2ddc Replace workflows for CI workflow 2025-04-18 13:18:54 -03:00
Christian Tosta
003a05b17a Replace workflows for CI workflow 2025-04-18 13:17:24 -03:00
Christian Tosta
2a1c30ea74 Updated build RPM workflow 2025-04-18 11:57:12 -03:00
Christian Tosta
4bc89cd26b Updated build RPM workflow 2025-04-18 11:53:21 -03:00
Christian Tosta
f3c14cd2f6 Updated build RPM workflow 2025-04-18 11:47:34 -03:00
Christian Tosta
229fd03b51 Updated build RPM workflow 2025-04-18 11:43:12 -03:00
Christian Tosta
af6642198d Updated build RPM workflow 2025-04-18 11:40:07 -03:00
Christian Tosta
0604d891f1 Updated build RPM workflow 2025-04-18 11:34:12 -03:00
Christian Tosta
db7e33ce50 Added build RPM workflow 2025-04-18 11:32:00 -03:00
Christian Tosta
0e6cc7f9a4 Updated auto-tagging workflow 2025-04-18 11:01:33 -03:00
Christian Tosta
a008f27813 Added auto-tagging workflow 2025-04-18 10:51:42 -03:00
Christian Tosta
47529209d4 Add RPM packaging support 2025-04-18 10:22:15 -03:00
Christian Tosta
3df218f8e7 Save version on file 2025-04-18 10:18:48 -03:00
Christian Tosta
4b2bdb47bf CA PKI update tool autodetection (legacy/p11kit) 2025-04-16 08:39:53 -03:00
Christian Tosta
921cab191b Update README.md 2025-03-27 05:22:55 -03:00
Christian Tosta
bdc70acaaf Initial commit 2025-03-27 05:20:04 -03:00
10 changed files with 453 additions and 0 deletions

52
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
name: Build and Release CI
on:
push:
schedule:
- cron: '30 3 * * *'
workflow_dispatch:
jobs:
release-ci:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.get_metadata.outputs.VERSION }}
steps:
- name: Local checkout
uses: actions/checkout@v4
- name: Install CI dependencies
run: |
sudo apt-get update
sudo apt-get -y -qq install cmake g++ gcc
- name: Get latest package metadata
id: get_metadata
run: |
cmake --fresh -B build -S .
echo "TAG=v$(cat build/version)" >> $GITHUB_OUTPUT
echo "VERSION=$(cat build/version)" >> $GITHUB_OUTPUT
- name: Check if package version has corresponding git tag
id: tagged
shell: bash
run: |
git show-ref \
--tags --verify --quiet -- \
"refs/tags/${{ steps.get_metadata.outputs.TAG }}" \
&& echo tagged=1 >> $GITHUB_OUTPUT \
|| echo tagged=0 >> $GITHUB_OUTPUT
- name: Create new tag
if: steps.tagged.outputs.tagged == 0
run: |
git tag ${{ steps.get_metadata.outputs.TAG }} \
&& git push origin ${{ steps.get_metadata.outputs.TAG }} \
|| exit 0
build-fedora:
needs: release-ci
uses: ./.github/workflows/fedora.yml
with:
containers: "['fedora:latest', 'fedora:41']"
version: ${{ needs.release-ci.outputs.VERSION }}

79
.github/workflows/fedora.yml vendored Normal file
View File

@@ -0,0 +1,79 @@
#name: build-rpm
on:
workflow_call:
inputs:
containers:
required: true
type: string
version:
required: false
type: string
jobs:
build:
strategy:
max-parallel: 2
matrix:
image: ${{ fromJson(inputs.containers) }}
runs-on: ubuntu-latest
container: ${{ matrix.image }}
steps:
- name: Local checkout
uses: actions/checkout@v4
- name: install RPM build dependencies
run: |
dnf -y install \
cmake \
gcc \
gcc-c++ \
git \
rpm-build \
rpmdevtools \
tar
- name: Setup RPM build tree
run: |
rpmdev-setuptree
- name: Create source tarball
run: |
cmake --fresh -B build -S .
cmake --build build --target sdist
- name: Set environment variables
run: |
echo "PKG_VERSION=$(cat build/version)" >> $GITHUB_ENV
echo "PKG_NAME=$(grep -Po 'Name:\ *\K[\S ]*' \
packaging/pkg.spec.in)" >> $GITHUB_ENV
- name: Copy SOURCES and SPEC file
run: |
cp packaging/pkg.spec.in ~/rpmbuild/SPECS/${PKG_NAME}.spec
rpmdev-bumpspec -n ${PKG_VERSION} ~/rpmbuild/SPECS/${PKG_NAME}.spec
cp dist/*.src.tar.gz ~/rpmbuild/SOURCES/
- name: Build RPM packages
run: |
dnf -y builddep ~/rpmbuild/SPECS/${PKG_NAME}.spec
rpmbuild -ba ~/rpmbuild/SPECS/${PKG_NAME}.spec
- name: Check if package version has corresponding git tag
id: tagged
shell: bash
run: |
git show-ref \
--tags --verify --quiet -- \
"refs/tags/${NEW_TAG}" \
&& echo tagged=1 >> $GITHUB_OUTPUT \
|| echo tagged=0 >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag' && steps.tagged.output.tagged == 1
with:
files: |
~/rpmbuild/RPMS/*/*.rpm
~/rpmbuild/SRPMS/*.rpm

17
.gitignore vendored Normal file
View File

@@ -0,0 +1,17 @@
.cache
.clang-format
.clangd
.idea
cmake-build*
build/
_CPack_Packages/
CMakeFiles/
Makefile
cmake_install.cmake
CPackConfig.cmake
CPackSourceConfig.cmake
CTestTestfile.cmake
CMakeCache.txt
dist/

113
CMakeLists.txt Normal file
View File

@@ -0,0 +1,113 @@
cmake_minimum_required(VERSION 3.16)
project(ca-certificates-brazil)
set(HASH_FILE "hashsha512.txt")
execute_process(
COMMAND bash -c
"date +%Y.%m.%d \
-d \"$( \
curl -ksI $(grep ${HASH_FILE} ${CMAKE_SOURCE_DIR}/sources) \
| grep -iPo '^Last-Modified: \\K[\\S ]*'
)\"
"
OUTPUT_VARIABLE PROJECT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND echo ${PROJECT_VERSION}
OUTPUT_FILE ${CMAKE_BINARY_DIR}/version
)
set(SourceFiles
"${CMAKE_SOURCE_DIR}/cmake"
"${CMAKE_SOURCE_DIR}/CMakeLists.txt"
"${CMAKE_SOURCE_DIR}/CPackLists.txt"
"${CMAKE_SOURCE_DIR}/sources"
)
include(CPackLists.txt)
add_custom_target(clear-certs
COMMAND rm -rf
certs/
pki/
)
add_custom_target(certs
COMMAND xargs -n1
curl
--create-dirs
--output-dir certs
-ksO < ${CMAKE_CURRENT_SOURCE_DIR}/sources
&& cd certs
&& (sha512sum -c --quiet ${HASH_FILE} || exit -1)
&& unzip ACcompactado.zip
DEPENDS
clear-certs
)
add_custom_target(isrg-root-x2.crt
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/crt2bundle.sh
pki/ca-trust-source/anchors/isrg-root-x2.crt
certs/isrg-root-x2.pem
DEPENDS
certs
)
add_custom_target(lets-encrypt-ca-bundle.crt
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/crt2bundle.sh
pki/ca-trust-source/anchors/lets-encrypt-ca-bundle.crt
certs/lets-encrypt-e1.pem
certs/lets-encrypt-e2.pem
certs/lets-encrypt-r3.pem
certs/lets-encrypt-r4.pem
DEPENDS
certs
)
add_custom_target(icp-brasil-ca-bundle.crt
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/crt2bundle.sh
pki/ca-trust-source/anchors/icp-brasil-ca-bundle.crt
certs/*.crt
DEPENDS
certs
)
add_custom_target(anchors ALL
DEPENDS
isrg-root-x2.crt
lets-encrypt-ca-bundle.crt
icp-brasil-ca-bundle.crt
)
# Checks which tool is used to update certificate keyring
find_program(UPDATE_CACERTS_TOOL
NAMES
update-ca-certificates
update-ca-trust
REQUIRED
)
message("-- Check for CA certificates update tool: ${UPDATE_CACERTS_TOOL}")
string(REGEX MATCH "update-ca-trust" P11KIT UPDATE_CACERTS_TOOL)
string(REGEX MATCH "update-ca-certificates" LEGACY UPDATE_CACERTS_TOOL)
# Set install destination directory according the used tool
if(DEFINED P11KIT)
set(CACERT_INSTALL_DIR "share/pki/ca-trust-source/anchors")
else()
set(CACERT_INSTALL_DIR "share/ca-certificates/extra")
endif()
message("-- Set install path to CA certificates: ${CACERT_INSTALL_DIR}")
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/pki/ca-trust-source/anchors/isrg-root-x2.crt
${CMAKE_CURRENT_BINARY_DIR}/pki/ca-trust-source/anchors/lets-encrypt-ca-bundle.crt
${CMAKE_CURRENT_BINARY_DIR}/pki/ca-trust-source/anchors/icp-brasil-ca-bundle.crt
DESTINATION
${CMAKE_INSTALL_PREFIX}/${CACERT_INSTALL_DIR}
)
# vim: ts=2:sw=2:sts=2:et

80
CPackLists.txt Normal file
View File

@@ -0,0 +1,80 @@
cmake_minimum_required(VERSION 3.16)
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_OUTPUT_FILE_PREFIX "${PROJECT_SOURCE_DIR}/dist")
set(CPACK_VERBATIM_VARIABLES YES)
set(SourceIgnoreFiles
".cache"
".clang-format"
".clangd"
".git/"
".gitea/"
".github/"
".gitignore"
".idea"
"CMakeCache.txt"
"CMakeFiles/"
"CPackConfig.cmake$"
"CPackSourceConfig.cmake"
"CTestTestfile.cmake"
"Makefile"
"_CPack_Packages/"
"build/"
"cmake-build*"
"cmake_install.cmake"
"dist/"
)
# Escape any '.' and '/' characters
string(REPLACE "." "\\\." SourceIgnoreFiles "${SourceIgnoreFiles}")
string(REPLACE "/" "\\\/" SourceIgnoreFiles "${SourceIgnoreFiles}")
# Override install prefix for package target
string(REGEX REPLACE "^/(.*)" "\\1"
CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
)
set(CPACK_SET_DESTDIR ON)
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_TOPLEVEL_TAG "noarch")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}.${CPACK_PACKAGE_TOPLEVEL_TAG}")
set(CPACK_IGNORE_FILES "${SourceIgnoreFiles}")
set(CPACK_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackConfig.cmake")
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/CPackConfig.cmake.in"
"${PROJECT_BINARY_DIR}/CPackConfig.cmake"
@ONLY
)
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_TOPLEVEL_TAG "src")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}.${CPACK_SOURCE_TOPLEVEL_TAG}")
set(CPACK_SOURCE_IGNORE_FILES "${SourceIgnoreFiles}")
set(CPACK_SOURCE_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackSourceConfig.cmake")
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/CPackConfig.cmake.in"
"${PROJECT_BINARY_DIR}/CPackSourceConfig.cmake"
@ONLY
)
include(CPack)
add_custom_target(sdist
COMMAND "${CMAKE_COMMAND}"
--build "${CMAKE_BINARY_DIR}"
--target package_source
VERBATIM
USES_TERMINAL
)
add_custom_target(bdist
COMMAND "${CMAKE_COMMAND}"
--build "${CMAKE_BINARY_DIR}"
--target package
VERBATIM
USES_TERMINAL
)
# vim: ts=2:sw=2:sts=2:et:syntax=cmake

View File

@@ -1,2 +1,12 @@
# ca-certificates-brazil # ca-certificates-brazil
The Brazilian Public Key Infrastructure: ICP-Brasil The Brazilian Public Key Infrastructure: ICP-Brasil
## Description
The Brazilian Public Key Infrastructure - ICP-Brasil is a hierarchical chain
of trust that enables the issuance of digital certificates for the virtual
identification of citizens.
It is observed that the model adopted by Brazil was single-root certification,
and the ITI, in addition to playing the role of Root Certifying Authority - Root AC,
also has the role of accrediting and discrediting the other participants in the
chain, supervise and audit the processes.

View File

@@ -0,0 +1,29 @@
# This file will be configured to contain variables for CPack. These variables
# should be set in the CMake list file of the project before CPack module is
# included. Example variables are:
# CPACK_GENERATOR - Generator used to create package
# CPACK_INSTALL_CMAKE_PROJECTS - For each project (path, name, component)
# CPACK_CMAKE_GENERATOR - CMake Generator used for the projects
# CPACK_INSTALL_COMMANDS - Extra commands to install components
# CPACK_INSTALL_DIRECTORIES - Extra directories to install
# CPACK_PACKAGE_DESCRIPTION_FILE - Description file for the package
# CPACK_PACKAGE_DESCRIPTION_SUMMARY - Summary of the package
# CPACK_PACKAGE_EXECUTABLES - List of pairs of executables and labels
# CPACK_PACKAGE_FILE_NAME - Name of the package generated
# CPACK_PACKAGE_ICON - Icon used for the package
# CPACK_PACKAGE_INSTALL_DIRECTORY - Name of directory for the installer
# CPACK_PACKAGE_NAME - Package project name
# CPACK_PACKAGE_VENDOR - Package project vendor
# CPACK_PACKAGE_VERSION - Package project version
# CPACK_PACKAGE_VERSION_MAJOR - Package project version (major)
# CPACK_PACKAGE_VERSION_MINOR - Package project version (minor)
# CPACK_PACKAGE_VERSION_PATCH - Package project version (patch)
# There are certain generator specific ones
# NSIS Generator:
# CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Name of the registry key for the installer
# CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS - Extra commands used during uninstall
# CPACK_NSIS_EXTRA_INSTALL_COMMANDS - Extra commands used during install
@_CPACK_OTHER_VARIABLES_@

14
crt2bundle.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
out=${1}
mkdir -p $(dirname ${out})
shift
in=''
for c in ${*}; do
echo "+ Loading CA certificate: ${c}";
in="${in} -certfile ${c}";
done;
openssl crl2pkcs7 -nocrl ${in} \
| openssl pkcs7 -print_certs -out ${out}

52
packaging/pkg.spec.in Normal file
View File

@@ -0,0 +1,52 @@
%global debug_package %{nil}
%global source_date_epoch_from_changelog 0
%define __openssl %{_bindir}/openssl
Name: ca-certificates-brazil
Version: __VERSION__
Release: %{autorelease}
Summary: The ICP-Brasil root certificate bundle
License: Public Domain
URL: https://www.gov.br/iti/pt-br/assuntos/certificado-digital
Source0: %{name}-%{version}.src.tar.gz
BuildArch: noarch
BuildRequires: %{__openssl}
BuildRequires: %{_bindir}/mktemp
BuildRequires: %{_bindir}/unzip
%description
The Brazilian Public Key Infrastructure - ICP-Brasil is a hierarchical chain
of trust that enables the issuance of digital certificates for the virtual
identification of citizens.
It is observed that the model adopted by Brazil was single-root certification,
and the ITI, in addition to playing the role of Root Certifying Authority - Root AC,
also has the role of accrediting and discrediting the other participants in the
chain, supervise and audit the processes.
%prep
%autosetup -c
%{cmake}
%build
%{cmake_build}
%install
%{__rm} -rf %{buildroot}
%{cmake_install}
%files
%{_datadir}/pki/ca-trust-source/anchors/isrg-root-x2.crt
%{_datadir}/pki/ca-trust-source/anchors/lets-encrypt-ca-bundle.crt
%{_datadir}/pki/ca-trust-source/anchors/icp-brasil-ca-bundle.crt
%post -p %{_bindir}/update-ca-trust
%postun -p %{_bindir}/update-ca-trust
%changelog
%autochangelog

7
sources Normal file
View File

@@ -0,0 +1,7 @@
https://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip
https://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/hashsha512.txt
https://letsencrypt.org/certs/isrg-root-x2.pem
https://letsencrypt.org/certs/lets-encrypt-e1.pem
https://letsencrypt.org/certs/lets-encrypt-e2.pem
https://letsencrypt.org/certs/lets-encrypt-r3.pem
https://letsencrypt.org/certs/lets-encrypt-r4.pem