Skip to content

Instantly share code, notes, and snippets.

@kostecky
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kostecky/f8814178b3367219544e to your computer and use it in GitHub Desktop.
Save kostecky/f8814178b3367219544e to your computer and use it in GitHub Desktop.
nginx / unicorn rack middleware to get a client cert to the puppetmaster
class String
def in_groups_of(n)
chars.each_slice(n).map(&:join).join("\n")
end
end
class SSL_Middleware
def initialize(app, options = {})
@app = app
@options = options
end
def call(env)
env["SSL_CLIENT_CERT"] = "-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----" % [env["HTTP_SSL_CLIENT_CERT"].in_groups_of(65)]
# continue processing
@app.call(env)
end
end
use SSL_Middleware
@kostecky
Copy link
Author

Place this at the top of your /etc/puppet/config.ru to enable trusted facts in a nginx/unicorn configuration.

This will solve the issue of getting tons of "TrustedInformation expected a certificate, but none was given." in your puppet logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment