Module: VagrantPlugins::Certificates::Cap::Windows::UpdateCertificateBundle

Defined in:
lib/vagrant-certificates/cap/windows/update_certificate_bundle.rb

Overview

Capability for configuring the certificate bundle on CoreOS.

Class Method Summary collapse

Class Method Details

.update_certificate_bundle(m) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/vagrant-certificates/cap/windows/update_certificate_bundle.rb', line 7

def self.update_certificate_bundle(m)
  # Import the certificates into the local machine root store
  m.communicate.sudo("Get-ChildItem -Path C:/ssl/certs | Foreach-Object {certutil -addstore -enterprise -f 'Root' $_.FullName}")
  # Also import the certificates into a bundle to be referenced by SSL_CERT_FILE
  m.communicate.sudo("Remove-Item -Path C:/ssl/cacert.pem; Get-ChildItem -Path C:/ssl/certs | Get-Content | Out-File -FilePath C:/ssl/cacert.pem -Encoding utf8 -Append")
  # Convert the cacerts.pem with Windows line endings ('\r\n') to Unix line endings ('\n')
  m.communicate.sudo("$cacertContents = [io.file]::ReadAllText('C:/ssl/cacert.pem') -replace \"`r`n\",\"`n\"; [io.file]::WriteAllText('C:/ssl/cacert_unix.pem', $cacertContents)")
end