Sha256: 2813477f8e428406fa2afc898181dbbad5ac1f37eb65df67a76745aa1537daae

Contents?: true

Size: 1.28 KB

Versions: 38

Compression:

Stored size: 1.28 KB

Contents

function New-ClientCertificate {
  param([String]$username, [String]$basePath = ((Resolve-Path .).Path))

  $env:OPENSSL_CONF=[System.IO.Path]::GetTempFileName()

  Set-Content -Path $env:OPENSSL_CONF -Value @"
  distinguished_name = req_distinguished_name
  [req_distinguished_name]
  [v3_req_client]
  extendedKeyUsage = clientAuth
  subjectAltName = otherName:1.3.6.1.4.1.311.20.2.3;UTF8:$username@localhost
"@

  $user_path = Join-Path $basePath user.pem
  $key_path = Join-Path $basePath key.pem
  $pfx_path = Join-Path $basePath user.pfx

  openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -out $user_path -outform PEM -keyout $key_path -subj "/CN=$username" -extensions v3_req_client 2>&1

  openssl pkcs12 -export -in $user_path -inkey $key_path -out $pfx_path -passout pass: 2>&1

  del $env:OPENSSL_CONF
}

function New-WinrmUserCertificateMapping {
  param([String]$issuer)
  $secure_pass = ConvertTo-SecureString $env:winrm_password -AsPlainText -Force
  $cred = New-Object System.Management.Automation.PSCredential ($env:winrm_user, $secure_pass)
  New-Item -Path WSMan:\localhost\ClientCertificate -Subject "$env:winrm_user@localhost" -URI * -Issuer $issuer -Credential $cred -Force
}

Export-ModuleMember New-ClientCertificate, New-WinrmUserCertificateMapping

Version data entries

38 entries across 30 versions & 3 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/WinrmAppveyor.psm1
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/WinrmAppveyor.psm1
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/WinrmAppveyor.psm1
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/WinrmAppveyor.psm1
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.3.0/WinrmAppveyor.psm1
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
winrm-2.3.0 WinrmAppveyor.psm1
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/winrm-2.2.3/WinrmAppveyor.psm1