Automating Puppet Certificates Renewal
Raphaël Pinson
2/19www.camptocamp.com /
Who am I?
■ Raphaël Pinson (@raphink)
○ Infrastructure Developer & Training Leader
○ Augeas & Augeasproviders developer
○ Various contributions to Puppet & Ecosystem
3/19www.camptocamp.com /
Camptocamp
■ Switzerland / France / Germany
■ Open-source development/integration expert
■ Puppet user and contributor since 2008
■ Major contributor to the Puppet Forge
4/19www.camptocamp.com /
Camptocamp infra team
5/19www.camptocamp.com /
CA cert has expired
6/19www.camptocamp.com /
CA renewal options
NEWCAKEY
PAIR
NEWCACERT
FROMKEYPAIR
AUTOMATECA
CERTDEPLOYMENT
AUTOMATEAGENT
CERTDEPLOYMENT
7/19www.camptocamp.com /
8/19www.camptocamp.com /
puppetlabs/certgen
■ Install from Puppet Forge
mod 'puppetlabs-certregen', '0.2.0'
■ Regenerate CA cert
$ sudo puppet certregen ca ca_serial 01–
■ Deploy new CA cert (before it expires!)
include certregen::client
9/19www.camptocamp.com /
How about agent certificates?
10/19www.camptocamp.com /
Certificate autosign
■ autosign.conf
○ Insecure by design
○ Don't use
■ Autosign policy
○ (possibly) secure autosigning
○ Use psk, unique tokens, etc.
○ See also danieldreier/puppet-autosign
11/19www.camptocamp.com /
The puppet_certificate type
■ Automate Puppet
certificate generation
■ Manage with Puppet
manifests
12/19www.camptocamp.com /
Cleaning certificats on CA
■ Required before new certificate
can be generated
■ Requires to tune the CA API in auth.conf
{
name: "Allow nodes to delete their own certificates",
match-request: {
path: "^/puppet-ca/v1/certificate(_status|_request)?/([^/]+)$"
type: regex
method: [delete]
},
Allow: "$2",
sort-order: 500
}
13/19www.camptocamp.com /
Unique renewal tokens
■ Use hashed token incl. unchangeable trusted facts
■ Sample hashing function (compatible with Terraform's
base64sha256 builtin function)
■ Generate unique token per node in Puppet manifest:
Puppet::Parser::Functions.newfunction(:base64_sha256, :arity => 1, :type => :rvalue) do |args|
Digest::SHA256.base64digest(args[0])
end
# $psk is a secret parameter (e.g. from hiera)
# $certname comes from trusted facts
$token = base64_sha256("${psk}/${certname}")
14/19www.camptocamp.com /
Adapt autosign script
#!/usr/bin/env ruby
require 'openssl'
request = STDIN.read
csr = OpenSSL::X509::Request.new(request)
# Don't you love OpenSSL's nested values?
challenge = csr.attributes.select { |a| a.oid == "challengePassword" }.first.value.value.first.value
# Puppetmaster logs include exit code
exit 2 if challenge.nil?
certname = ARGV[0]
hash = Digest::SHA256.base64digest("#{autosign_psk}/#{certname}")
if challenge == hash
exit 0
end
exit 1
15/19www.camptocamp.com /
Throw in certificate extensions
def get_ext(csr, name)
Puppet::SSL::Oids.register_puppet_oids
# Some more OpenSSL nested values
exts = csr.attributes.select{ |a| a.oid == "extReq" }[0].value.value[0].value
# Turtles all the way down
val = exts.select { |e| e.value[0].short_name == name }[0].value[1].value
OpenSSL::ASN1.decode(val).value
end
pp_role = get_ext(csr, 'pp_role')
pp_environment = get_ext(csr, 'pp_environment')
hash = Digest::SHA256.base64digest("#{autosign_psk}/#{certname}/#{pp_role}/#{pp_environment}")
■ Lock token to specific trusted facts
16/19www.camptocamp.com /
Couple with trusted facts provisioning
$role = $::trusted['extensions']['pp_role']
include sprintf(
'::roles_c2c::%s', regsubst($role, '/', '::', 'G')
)
■ Dynamic provisioning (no server code added)
■ Safe because linked to certificate
17/19www.camptocamp.com /
Put it all together!
# csr_attributes.yaml
---
custom_attributes:
1.2.840.113549.1.9.7: '$
{token}'
# in common Puppet profile
puppet_certificate { $certname:
ensure => valid,
waitforcert => 60,
renewal_grace_period => 20,
clean => true,
}
18/19www.camptocamp.com /
Automating Puppet Certificates Renewal

More Related Content

PDF
Automating Puppet Certificates Renewal
PDF
Php arduino
PDF
Hadoop meetup : HUGFR Construire le cluster le plus rapide pour l'analyse des...
PDF
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
PDF
Orchestrated Functional Testing with Puppet-spec and Mspectator
PDF
georchestra SDI: Project Status Report
PDF
1032 practical linux system administration
PDF
Dependencies Managers in C/C++. Using stdcpp 2014
Automating Puppet Certificates Renewal
Php arduino
Hadoop meetup : HUGFR Construire le cluster le plus rapide pour l'analyse des...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator
georchestra SDI: Project Status Report
1032 practical linux system administration
Dependencies Managers in C/C++. Using stdcpp 2014

Similar to Automating Puppet Certificates Renewal (20)

PDF
First steps with Gazebo simulation for ROS
PDF
Create your very own Development Environment with Vagrant and Packer
PDF
Icinga 2 and Puppet - Automate Monitoring
PDF
Icinga Camp Amsterdam - Icinga2 and Puppet
PDF
Python para equipos de ciberseguridad
PDF
Test-Driven Puppet Development - PuppetConf 2014
PDF
Puppet at Pinterest
PDF
Spark summit2014 techtalk - testing spark
PDF
Our Puppet Story (GUUG FFG 2015)
PPTX
Apache Spark SQL- Installing Spark
PDF
Symfony War Stories
PDF
Piwik elasticsearch kibana at OSC Tokyo 2016 Spring
PDF
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
PDF
Infinum Android Talks #04 - How to publish an android archive (.aar) to Maven...
PDF
OpenStack for Centos
PPTX
Virtualization and automation of library software/machines + Puppet
PDF
Adding replication protocol support for psycopg2
PDF
Introducing Playwright's New Test Runner
PDF
Beyond AEM Curl Commands
PDF
PuppetCamp SEA 1 - Use of Puppet
First steps with Gazebo simulation for ROS
Create your very own Development Environment with Vagrant and Packer
Icinga 2 and Puppet - Automate Monitoring
Icinga Camp Amsterdam - Icinga2 and Puppet
Python para equipos de ciberseguridad
Test-Driven Puppet Development - PuppetConf 2014
Puppet at Pinterest
Spark summit2014 techtalk - testing spark
Our Puppet Story (GUUG FFG 2015)
Apache Spark SQL- Installing Spark
Symfony War Stories
Piwik elasticsearch kibana at OSC Tokyo 2016 Spring
Infinum Android Talks #04 - How to publish an Android archive (.aar) to Maven...
Infinum Android Talks #04 - How to publish an android archive (.aar) to Maven...
OpenStack for Centos
Virtualization and automation of library software/machines + Puppet
Adding replication protocol support for psycopg2
Introducing Playwright's New Test Runner
Beyond AEM Curl Commands
PuppetCamp SEA 1 - Use of Puppet
Ad

More from Raphaël PINSON (20)

PDF
Explore the World of Cilium, Tetragon & eBPF
PDF
Cfgmgmtcamp 2024 — eBPF-based Security Observability & Runtime Enforcement wi...
PDF
ContainerDays Hamburg 2023 — Cilium Workshop.pdf
PDF
KCD Zurich 2023 — Bridge Dev & Ops with eBPF.pdf
PDF
Cloud Native Bern 05.2023 — Zero Trust Visibility
PDF
DevOpsDays Zurich 2023 — Bridging Dev and Ops with eBPF: Extending Observabil...
PPTX
Révolution eBPF - un noyau dynamique
PPTX
Cfgmgmtcamp 2023 — eBPF Superpowers
PDF
Cloud Native Networking & Security with Cilium & eBPF
PDF
2022 DevOpsDays Geneva — The Hare and the Tortoise.pdf
PDF
SKS in git ops mode
PDF
The Hare and the Tortoise: Open Source, Standards & Technological Debt
PDF
Devops stack
PDF
YAML Engineering: why we need a new paradigm
PDF
Container Security: a toolchain for automatic image rebuilds
PDF
K9s - Kubernetes CLI To Manage Your Clusters In Style
PDF
Argocd up and running
PDF
Bivac - Container Volumes Backup
PDF
Running the Puppet Stack in Containers
PDF
Narcissus — mapping configs in Go
Explore the World of Cilium, Tetragon & eBPF
Cfgmgmtcamp 2024 — eBPF-based Security Observability & Runtime Enforcement wi...
ContainerDays Hamburg 2023 — Cilium Workshop.pdf
KCD Zurich 2023 — Bridge Dev & Ops with eBPF.pdf
Cloud Native Bern 05.2023 — Zero Trust Visibility
DevOpsDays Zurich 2023 — Bridging Dev and Ops with eBPF: Extending Observabil...
Révolution eBPF - un noyau dynamique
Cfgmgmtcamp 2023 — eBPF Superpowers
Cloud Native Networking & Security with Cilium & eBPF
2022 DevOpsDays Geneva — The Hare and the Tortoise.pdf
SKS in git ops mode
The Hare and the Tortoise: Open Source, Standards & Technological Debt
Devops stack
YAML Engineering: why we need a new paradigm
Container Security: a toolchain for automatic image rebuilds
K9s - Kubernetes CLI To Manage Your Clusters In Style
Argocd up and running
Bivac - Container Volumes Backup
Running the Puppet Stack in Containers
Narcissus — mapping configs in Go
Ad

Recently uploaded (20)

PDF
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
PPTX
Airline CRS | Airline CRS Systems | CRS System
PPTX
Cybersecurity: Protecting the Digital World
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
Workplace Software and Skills - OpenStax
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
Matchmaking for JVMs: How to Pick the Perfect GC Partner
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PDF
Internet Download Manager IDM Crack powerful download accelerator New Version...
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PPTX
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
Airline CRS | Airline CRS Systems | CRS System
Cybersecurity: Protecting the Digital World
Full-Stack Developer Courses That Actually Land You Jobs
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Workplace Software and Skills - OpenStax
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
GSA Content Generator Crack (2025 Latest)
Matchmaking for JVMs: How to Pick the Perfect GC Partner
Trending Python Topics for Data Visualization in 2025
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
Internet Download Manager IDM Crack powerful download accelerator New Version...
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
Topaz Photo AI Crack New Download (Latest 2025)
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .

Automating Puppet Certificates Renewal

  • 1. Automating Puppet Certificates Renewal Raphaël Pinson
  • 2. 2/19www.camptocamp.com / Who am I? ■ Raphaël Pinson (@raphink) ○ Infrastructure Developer & Training Leader ○ Augeas & Augeasproviders developer ○ Various contributions to Puppet & Ecosystem
  • 3. 3/19www.camptocamp.com / Camptocamp ■ Switzerland / France / Germany ■ Open-source development/integration expert ■ Puppet user and contributor since 2008 ■ Major contributor to the Puppet Forge
  • 6. 6/19www.camptocamp.com / CA renewal options NEWCAKEY PAIR NEWCACERT FROMKEYPAIR AUTOMATECA CERTDEPLOYMENT AUTOMATEAGENT CERTDEPLOYMENT
  • 8. 8/19www.camptocamp.com / puppetlabs/certgen ■ Install from Puppet Forge mod 'puppetlabs-certregen', '0.2.0' ■ Regenerate CA cert $ sudo puppet certregen ca ca_serial 01– ■ Deploy new CA cert (before it expires!) include certregen::client
  • 10. 10/19www.camptocamp.com / Certificate autosign ■ autosign.conf ○ Insecure by design ○ Don't use ■ Autosign policy ○ (possibly) secure autosigning ○ Use psk, unique tokens, etc. ○ See also danieldreier/puppet-autosign
  • 11. 11/19www.camptocamp.com / The puppet_certificate type ■ Automate Puppet certificate generation ■ Manage with Puppet manifests
  • 12. 12/19www.camptocamp.com / Cleaning certificats on CA ■ Required before new certificate can be generated ■ Requires to tune the CA API in auth.conf { name: "Allow nodes to delete their own certificates", match-request: { path: "^/puppet-ca/v1/certificate(_status|_request)?/([^/]+)$" type: regex method: [delete] }, Allow: "$2", sort-order: 500 }
  • 13. 13/19www.camptocamp.com / Unique renewal tokens ■ Use hashed token incl. unchangeable trusted facts ■ Sample hashing function (compatible with Terraform's base64sha256 builtin function) ■ Generate unique token per node in Puppet manifest: Puppet::Parser::Functions.newfunction(:base64_sha256, :arity => 1, :type => :rvalue) do |args| Digest::SHA256.base64digest(args[0]) end # $psk is a secret parameter (e.g. from hiera) # $certname comes from trusted facts $token = base64_sha256("${psk}/${certname}")
  • 14. 14/19www.camptocamp.com / Adapt autosign script #!/usr/bin/env ruby require 'openssl' request = STDIN.read csr = OpenSSL::X509::Request.new(request) # Don't you love OpenSSL's nested values? challenge = csr.attributes.select { |a| a.oid == "challengePassword" }.first.value.value.first.value # Puppetmaster logs include exit code exit 2 if challenge.nil? certname = ARGV[0] hash = Digest::SHA256.base64digest("#{autosign_psk}/#{certname}") if challenge == hash exit 0 end exit 1
  • 15. 15/19www.camptocamp.com / Throw in certificate extensions def get_ext(csr, name) Puppet::SSL::Oids.register_puppet_oids # Some more OpenSSL nested values exts = csr.attributes.select{ |a| a.oid == "extReq" }[0].value.value[0].value # Turtles all the way down val = exts.select { |e| e.value[0].short_name == name }[0].value[1].value OpenSSL::ASN1.decode(val).value end pp_role = get_ext(csr, 'pp_role') pp_environment = get_ext(csr, 'pp_environment') hash = Digest::SHA256.base64digest("#{autosign_psk}/#{certname}/#{pp_role}/#{pp_environment}") ■ Lock token to specific trusted facts
  • 16. 16/19www.camptocamp.com / Couple with trusted facts provisioning $role = $::trusted['extensions']['pp_role'] include sprintf( '::roles_c2c::%s', regsubst($role, '/', '::', 'G') ) ■ Dynamic provisioning (no server code added) ■ Safe because linked to certificate
  • 17. 17/19www.camptocamp.com / Put it all together! # csr_attributes.yaml --- custom_attributes: 1.2.840.113549.1.9.7: '$ {token}' # in common Puppet profile puppet_certificate { $certname: ensure => valid, waitforcert => 60, renewal_grace_period => 20, clean => true, }