Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows_certificate_binding should allow rebinding to the specified subject or fingerpint #313

Open
hh opened this issue Dec 3, 2015 · 4 comments
Labels
Status: Sustaining Backlog An issue ideal for the Sustaining Engineering team (or anyone else if they want to adopt it). Triage: Feature Request Indicates an issue requesting new functionality.

Comments

@hh
Copy link
Contributor

hh commented Dec 3, 2015

As a windows chef user
I want to ensure a specific certificate binding to a port
In order to replace any existing binding with what I have specified

Given a certificate in pfx form
And it's successfully imported
When I write a windows_certificate_binding resource stanza
And specify the desired subject or fingerprint
And there is already another certificate bound to the desired port
Then the desired certificate binding should replace the existing one

What you currently have to do (using an encrypted data bag with password, subject and fingerpint, and a files/default/certificate.pfx):

iis_site 'Default Web Site' do
  action :config
  site_id 1
  bindings 'http/*:80:,net.tcp/808:*,net.pipe/*,net.msmq/localhost,msmq.formatname/localhost,https/*:443:'
end

decrypted = data_bag_item('passwords', "certificate")

pfx = "c:\\chef\\certificate.pfx"

cookbook_file pfx

windows_certificate pfx do
  pfx_password decrypted['password']
  store_name 'MY'
  user_store false
end

subject = decrypted['subject']
fingerprint = decrypted['fingerprint']

#removing the current one IF it doesn't match
windows_certificate_binding 'Unbind any non-matching certs' do
  action :delete
  name subject
  name_kind :subject
  address '0.0.0.0'
  guard_interpreter :powershell_script
  not_if <<-EOF
  Import-Module WebAdministration
  $x = Git-Item IIS:\SslBindings\0.0.0.0!443
  $x.Thumbprint.CompareTo("#{fingerprint}")
  EOF
end

# bind the correct one... this should be all we need to specify...
# if there is already a binding on this port... it does nothing
# it should replace it in my opinion
windows_certificate_binding 'Reuse RDP and WINRM self-signed cert for IIS' do
  action :create
  name_kind :subject
  name subject
  address '0.0.0.0'
end
@EasyAsABC123
Copy link
Contributor

You would only want this to happen on first run though correct? On the next run you wouldn't want it to replace every time. Perhaps adding the action [:add, :replace]?...

@hh
Copy link
Contributor Author

hh commented Dec 4, 2015

I don't think there needs to be two actions, it should be part of create (the specified binding of a port to a certificate should be [re]bound).

List of Certificates in Cert:\My
A, B, C, D

Previous Windows Bindings:
0.0.0.0:443 A

Then we apply

windows_certificate_binding 'B' do
  address '0.0.0.0'
end

New (and convergent) Windows Bindings:
0.0.0.0:443 B

If you specify B, it should make it bind to B. The second time through it will already be bound to B. No need to specify a new action.

@hh
Copy link
Contributor Author

hh commented Dec 4, 2015

This has no effect on the windows_certificates resources, just the bindings.

@EasyAsABC123
Copy link
Contributor

That sounds like [:create, :config] there just currently isn't a :config action

@tas50 tas50 added the Status: Sustaining Backlog An issue ideal for the Sustaining Engineering team (or anyone else if they want to adopt it). label Feb 2, 2019
@tas50 tas50 added Triage: Feature Request Indicates an issue requesting new functionality. and removed Type: Feature Request labels Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Sustaining Backlog An issue ideal for the Sustaining Engineering team (or anyone else if they want to adopt it). Triage: Feature Request Indicates an issue requesting new functionality.
Development

No branches or pull requests

3 participants