0

Using Chef to create a registry value for IIS8.5 SSL Binding as the only way I've found to create this value is through the IIS Manager.

I'm trying to use the following in the windows cookbook, but am having trouble escaping characters inside the data portion of this binary data. \, ', " don't appear to work here.

registry_key "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HTTP\\Parameters\\SslCcsBindingInfo\\443" do
    values [{:name => "AppId", :type => :binary, :data => "?áAMKá!J°"Yüf> ¶"},
            {:name => "CertStoreLocation", :type => :binary, :data => ""}
           ]
    action :create
end
user117529
  • 663
  • 8
  • 16
d_turner
  • 15
  • 5

2 Answers2

1

For binary values, I used something similar to regedit's display format:

binstring = [<<BINARY_HEX.tr('^0-9A-Fa-f','')].pack('H*')
08 00 00 00 00 00 00 00
6F 00 77 00 00 00 00 00
00 00 00 00 00 00
BINARY_HEX

registry_key 'HKCU\Software\Something\Item' do
  values [{:name => 'ABinaryValue', :type => :binary, :data => binstring},
         ]
  action :create
end

This made it easier to visually compare binary values in the Registry Editor to the intended values in recipes.

Ref: Convert string with hex ASCII codes to characters

Community
  • 1
  • 1
user117529
  • 663
  • 8
  • 16
0

For encoding binary data you are probably best off either using a base64'd string literal:

require 'base64'
values [{:data => Base64.decode64("YmluYXJ5ZGF0YQ==")}]

or using the \x escape sequence:

values [{:data => "\x45\xA0\xFF\x00"}]
coderanger
  • 52,400
  • 4
  • 52
  • 75
  • The \x escape sequence worked for me. I'm wondering though, as this would make life easier, if in Chef you can have it modify the hex data instead of the ASCII data inside binary registry entries? – d_turner Nov 10 '14 at 15:19