Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. $hostname = $env:computername.ToLower()
  2. $domain = $env:userdnsdomain.ToLower()
  3.  
  4. $templ = @"
  5. [Version]
  6. Signature="$Windows NT$
  7.  
  8. [NewRequest]
  9. Subject = "CN=$hostname.$domain"
  10. Exportable = FALSE
  11. KeySpec = 1
  12. KeyUsage = 0xA0
  13. MachineKeySet = True
  14. ProviderType = 12
  15. RequestType = PKCS10
  16. ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
  17. KeyLength = 2048
  18. "@
  19.  
  20. $templ | Out-File req.inf
  21.  
  22. # Fetch CA certificate and install it
  23. Invoke-WebRequest -Uri http://ca7.certidude.rocks/api/certificate -OutFile ca_cert.pem
  24.  
  25. #Import-Certificate -FilePath ca_cert.pem -CertStoreLocation Cert:\LocalMachine\Root
  26. C:\Windows\system32\certutil.exe -addstore Root ca_cert.pem
  27.  
  28. # Generate keypair and submit CSR
  29. C:\Windows\system32\certreq.exe -new -f -q req.inf client_csr.pem
  30. Invoke-WebRequest -TimeoutSec 900 -Uri 'http://ca7.certidude.rocks/api/request/?autosign=1' -InFile client_csr.pem -ContentType application/pkcs10 -Method POST -MaximumRedirection 3 -OutFile client_cert.pem
  31.  
  32. # Import certificate
  33. C:\Windows\system32\certutil.exe -addstore My client_cert.pem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement