DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Zero-Touch Patch Management With PowerShell and Intune: How We Automated Compliance at Scale
  • Multiplatform Directory Bookmarks on the Command Line
  • Effective Secrets Management: Retrieving Secrets From Azure Key Vault With Powershell Script
  • Apache Ranger and AWS EMR Automated Installation and Integration Series (5): Windows AD + Open-Source Ranger

Trending

  • Conversational Risk Accumulation: Stateful Guardrails Beyond Single-Turn LLM Checks
  • Optimizing Arm-Based Build Servers With AmpereOne CPUs
  • I Reverse-Engineered 50 API Breaches. The Same Five Mistakes Keep Appearing.
  • Top Java Security Vulnerabilities and How to Prevent Them in Modern Java
  1. DZone
  2. Coding
  3. Languages
  4. How to Create a Self-Signed Certificate With PowerShell [Snippet]

How to Create a Self-Signed Certificate With PowerShell [Snippet]

The development process often requires the use of a certificate, so let's learn how to make one using PowerShell.

By 
Michele Ferracin user avatar
Michele Ferracin
·
Updated Mar. 07, 19 · Code Snippet
Likes (2)
Comment
Save
Tweet
Share
20.3K Views

Join the DZone community and get the full member experience.

Join For Free

When we develop web-application or experiment with some technologies, it's quite common to need a certificate. A certificate for real world scenarios can be expensive, and it's over-engineering for testing purposes. So with this simple PowerShell script (on Windows), we can create a self-signed certificate for development enviroments.

$cert = New-SelfSignedCertificate -DnsName mydemowebapp.net -CertStoreLocation cert:\LocalMachine\My

$pwd = ConvertTo-SecureString -String "MyPassword" -Force -AsPlainText

Export-PfxCertificate -Cert $cert -FilePath C:\temp\cert.pfx -Password $pwd


With these few line of codes, we create and store a self-signed certificate in the Windows Certificate Store. With the last line (Export-PfxCertificate), we export the certificate for furher use for example to do some experiments with cloud providers.

Reference

GitHub Gist
PowerShell

Published at DZone with permission of Michele Ferracin. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Zero-Touch Patch Management With PowerShell and Intune: How We Automated Compliance at Scale
  • Multiplatform Directory Bookmarks on the Command Line
  • Effective Secrets Management: Retrieving Secrets From Azure Key Vault With Powershell Script
  • Apache Ranger and AWS EMR Automated Installation and Integration Series (5): Windows AD + Open-Source Ranger

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook