SlideShare a Scribd company logo
Automating Puppet Certificates Renewal
Raphaël Pinson
2/18www.camptocamp.com /
Who am I?
■ Raphaël Pinson (@raphink)
○ Infrastructure Developer & Training Leader
○ Augeas & Augeasproviders developer
○ Various contributions to Puppet & Ecosystem
3/18www.camptocamp.com /
Camptocamp
■ Switzerland / France / Germany
■ Open-source development/integration expert
■ ~ 90 employees
■ Puppet user and contributor since 2008
■ Main contributor to the Puppet Forge
4/18www.camptocamp.com /
CA cert has expired
5/18www.camptocamp.com /
CA renewal options
NEWCAKEY
PAIR
NEWCACERT
FROMKEYPAIR
AUTOMATECA
CERTDEPLOYMENT
AUTOMATEAGENT
CERTDEPLOYMENT
6/18www.camptocamp.com /
7/18www.camptocamp.com /
puppetlabs/certgen
■ Install from Puppet Forge
mod 'puppetlabs-certregen', '0.2.0'
■ Regenerate CA cert
$ sudo puppet certregen ca ca_serial 01–ca_serial 01
■ Deploy new CA cert (before it expires!)
include certregen::client
8/18www.camptocamp.com /
How about agent certificates?
9/18www.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
10/18www.camptocamp.com /
The puppet_certificate type
■ Automate Puppet
certificate generation
■ Manage with Puppet
manifests
11/18www.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
}
12/18www.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}")
13/18www.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
exit 3 if challenge.nil?
certname = ARGV[0]
hash = Digest::SHA256.base64digest("#{autosign_psk}/#{certname}")
if challenge == hash
exit 0
end
exit 1
14/18www.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
15/18www.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
16/18www.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,
}
17/18www.camptocamp.com /
Automating Puppet Certificates Renewal

More Related Content

PPTX
Symbolicate Crash 使用教學
PPTX
Testing & deploying terraform
PDF
Bee Smalltalk RunTime: anchor's aweigh
PDF
Automating Puppet Certificates Renewal
PDF
Orchestrated Functional Testing with Puppet-spec and Mspectator
PDF
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
PDF
Hadoop meetup : HUGFR Construire le cluster le plus rapide pour l'analyse des...
PDF
Puppet at Pinterest
Symbolicate Crash 使用教學
Testing & deploying terraform
Bee Smalltalk RunTime: anchor's aweigh
Automating Puppet Certificates Renewal
Orchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Hadoop meetup : HUGFR Construire le cluster le plus rapide pour l'analyse des...
Puppet at Pinterest

Similar to Automating Puppet Certificates Renewal (20)

PDF
Icinga Camp Amsterdam - Icinga2 and Puppet
PDF
Icinga 2 and Puppet - Automate Monitoring
PDF
Beyond AEM Curl Commands
KEY
Railsconf2011 deployment tips_for_slideshare
PDF
Spark summit2014 techtalk - testing spark
PDF
Dependencies Managers in C/C++. Using stdcpp 2014
PDF
How I hack on puppet modules
PDF
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
PDF
Create your very own Development Environment with Vagrant and Packer
PDF
Writing and Publishing Puppet Modules - PuppetConf 2014
PDF
Test-Driven Puppet Development - PuppetConf 2014
PDF
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
PDF
Our Puppet Story (GUUG FFG 2015)
KEY
10 Catalyst Tips
PDF
Osol Pgsql
PPT
2016年のPerl (Long version)
PDF
Introducing Playwright's New Test Runner
PDF
OpenStack for Centos
PDF
Automating Complex Setups with Puppet
PPTX
Virtualization and automation of library software/machines + Puppet
Icinga Camp Amsterdam - Icinga2 and Puppet
Icinga 2 and Puppet - Automate Monitoring
Beyond AEM Curl Commands
Railsconf2011 deployment tips_for_slideshare
Spark summit2014 techtalk - testing spark
Dependencies Managers in C/C++. Using stdcpp 2014
How I hack on puppet modules
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
Create your very own Development Environment with Vagrant and Packer
Writing and Publishing Puppet Modules - PuppetConf 2014
Test-Driven Puppet Development - PuppetConf 2014
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Our Puppet Story (GUUG FFG 2015)
10 Catalyst Tips
Osol Pgsql
2016年のPerl (Long version)
Introducing Playwright's New Test Runner
OpenStack for Centos
Automating Complex Setups with Puppet
Virtualization and automation of library software/machines + 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
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation theory and applications.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Assigned Numbers - 2025 - Bluetooth® Document
MYSQL Presentation for SQL database connectivity
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine Learning_overview_presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation theory and applications.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectral efficient network and resource selection model in 5G networks
20250228 LYD VKU AI Blended-Learning.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...

Automating Puppet Certificates Renewal

  • 1. Automating Puppet Certificates Renewal Raphaël Pinson
  • 2. 2/18www.camptocamp.com / Who am I? ■ Raphaël Pinson (@raphink) ○ Infrastructure Developer & Training Leader ○ Augeas & Augeasproviders developer ○ Various contributions to Puppet & Ecosystem
  • 3. 3/18www.camptocamp.com / Camptocamp ■ Switzerland / France / Germany ■ Open-source development/integration expert ■ ~ 90 employees ■ Puppet user and contributor since 2008 ■ Main contributor to the Puppet Forge
  • 5. 5/18www.camptocamp.com / CA renewal options NEWCAKEY PAIR NEWCACERT FROMKEYPAIR AUTOMATECA CERTDEPLOYMENT AUTOMATEAGENT CERTDEPLOYMENT
  • 7. 7/18www.camptocamp.com / puppetlabs/certgen ■ Install from Puppet Forge mod 'puppetlabs-certregen', '0.2.0' ■ Regenerate CA cert $ sudo puppet certregen ca ca_serial 01–ca_serial 01 ■ Deploy new CA cert (before it expires!) include certregen::client
  • 9. 9/18www.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
  • 10. 10/18www.camptocamp.com / The puppet_certificate type ■ Automate Puppet certificate generation ■ Manage with Puppet manifests
  • 11. 11/18www.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 }
  • 12. 12/18www.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}")
  • 13. 13/18www.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 exit 3 if challenge.nil? certname = ARGV[0] hash = Digest::SHA256.base64digest("#{autosign_psk}/#{certname}") if challenge == hash exit 0 end exit 1
  • 14. 14/18www.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
  • 15. 15/18www.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
  • 16. 16/18www.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, }