We help IT Professionals succeed at work.

Use New-SelfSignedCertificate to create a Trusted Root certificate

7,169 Views
Last Modified: 2017-05-09
I am trying to use New-SelfSignedCertificate to create a Trusted Root certificate and then to create some Personal certificates to use for local development testing (IIS).

I followed the instructions on this site http://blog.davidchristiansen.com/2016/09/howto-create-self-signed-certificates-with-powershell/

I used this to create the root certificate:
New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname "XXX Local Certificate Authority"

Open in new window


When I look at the certificate, the intended purposes are:

  • Proves your identity to a remote computer
  • Ensures the identity of a remote computer
  • All issuance policies

Rather than the expected:

  • All issuance policies
  • All application policies

I created a client certificate with:
New-SelfSignedCertificate -Subject *.testing.local  -DnsName *.testing.local, testing.local -CertStoreLocation Cert:\LocalMachine\My  -Signer $rootcert

Open in new window


Which seems to work, but the certificate says "This certificate is not valid for the selected purpose"

The certificates do kind of work in IIS, but I have Kaspersky and it keeps interrupting, saying certificate not valid (or something).
Comment
Watch Question

Chris DentPowerShell Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
You're going to need to do a bit more work to generate a CA certificate. That is, a certificate which is suitable for signing other certificates.

I suggest you start with this for the root certificate:
New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname "XXX Local Certificate Authority" -KeyusageProperty Sign

Open in new window

It might not be enough, but I can't test it, requires either Windows 10 or Server 2016 and I have neither here.
Gordon SaxbySenior Web Developer

Author

Commented:
Unfortunately, that didn't help (adding -KeyusageProperty Sign). The root cert appears to be exactly the same as before. I then created a client certificate and the problem still exists.

Selecting the root cert in the "Certification path" tab shows this in the status panel - "This certificate does not appear to be valid for the selected purpose." The Certificate Information panel (on general tab) says "This certificate is not valid for the selected purpose".
PowerShell Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Gordon SaxbySenior Web Developer

Author

Commented:
OK - I think that has sorted it (after I corrected a slight typo in your command - DigitalSignature rather than DigitalSiganture)

I'll try it for a bit longer before I close the question.
Chris DentPowerShell Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Amusingly, I inherited the typo from MS:

https://technet.microsoft.com/en-us/itpro/powershell/windows/pkiclient/new-selfsignedcertificate

Help section for the KeyUsage parameter.

Ah well, you fixed it, hopefully that's sufficient now :)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.