├── .gitignore ├── LICENSE ├── MakeCertificate.ps1 ├── README.md └── Screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | 154 | # Microsoft Azure Build Output 155 | csx/ 156 | *.build.csdef 157 | 158 | # Microsoft Azure Emulator 159 | ecf/ 160 | rcf/ 161 | 162 | # Microsoft Azure ApplicationInsights config file 163 | ApplicationInsights.config 164 | 165 | # Windows Store app package directory 166 | AppPackages/ 167 | BundleArtifacts/ 168 | 169 | # Visual Studio cache files 170 | # files ending in .cache can be ignored 171 | *.[Cc]ache 172 | # but keep track of directories ending in .cache 173 | !*.[Cc]ache/ 174 | 175 | # Others 176 | ClientBin/ 177 | ~$* 178 | *~ 179 | *.dbmdl 180 | *.dbproj.schemaview 181 | *.pfx 182 | *.publishsettings 183 | node_modules/ 184 | orleans.codegen.cs 185 | 186 | # RIA/Silverlight projects 187 | Generated_Code/ 188 | 189 | # Backup & report files from converting an old project file 190 | # to a newer Visual Studio version. Backup files are not needed, 191 | # because we have git ;-) 192 | _UpgradeReport_Files/ 193 | Backup*/ 194 | UpgradeLog*.XML 195 | UpgradeLog*.htm 196 | 197 | # SQL Server files 198 | *.mdf 199 | *.ldf 200 | 201 | # Business Intelligence projects 202 | *.rdl.data 203 | *.bim.layout 204 | *.bim_*.settings 205 | 206 | # Microsoft Fakes 207 | FakesAssemblies/ 208 | 209 | # GhostDoc plugin setting file 210 | *.GhostDoc.xml 211 | 212 | # Node.js Tools for Visual Studio 213 | .ntvs_analysis.dat 214 | 215 | # Visual Studio 6 build log 216 | *.plg 217 | 218 | # Visual Studio 6 workspace options file 219 | *.opt 220 | 221 | # Visual Studio LightSwitch build output 222 | **/*.HTMLClient/GeneratedArtifacts 223 | **/*.DesktopClient/GeneratedArtifacts 224 | **/*.DesktopClient/ModelManifest.xml 225 | **/*.Server/GeneratedArtifacts 226 | **/*.Server/ModelManifest.xml 227 | _Pvt_Extensions 228 | 229 | # Paket dependency manager 230 | .paket/paket.exe 231 | 232 | # FAKE - F# Make 233 | .fake/ 234 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Muhammad Rehan Saeed 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MakeCertificate.ps1: -------------------------------------------------------------------------------- 1 | Write-Host " __ ___ __ _____ __ _ ____ __ "; 2 | Write-Host " / |/ /__ _/ /_____ / ___/__ ____/ /_(_) _(_)_______/ /____ "; 3 | Write-Host " / /|_/ / _ `/ '_/ -_) / /__/ -_) __/ __/ / _/ / __/ _ `/ __/ -_)"; 4 | Write-Host "/_/ /_/\_,_/_/\_\\__/ \___/\__/_/ \__/_/_//_/\__/\__/\__/\__/ "; 5 | Write-Host; 6 | Write-Host "Makes certificate files by answering a few simple questions."; 7 | Write-Host " Learn: http://www.jayway.com/2014/09/03/creating-self-signed-certificates-with-makecert-exe-for-development/."; 8 | Write-Host " Author: Muhammad Rehan Saeed, RehanSaeed.com, @RehanSaeedUK"; 9 | Write-Host "Project: https://github.com/RehanSaeed/MakeCertificate" 10 | Write-Host "Version: 1.0"; 11 | Write-Host " Output: .cer - A public key file that can be shared."; 12 | Write-Host " .pvk - A private key file that should be kept secret."; 13 | Write-Host " .pfx - A combined public and private key file that should be kept secret."; 14 | Write-Host; 15 | 16 | $makecert = "C:\Program Files (x86)\Windows Kits\10\bin\x64\makecert.exe"; 17 | $pvk2pfx = "C:\Program Files (x86)\Windows Kits\10\bin\x64\pvk2pfx.exe"; 18 | 19 | do 20 | { 21 | Write-Host "What type of certificate do you want to create?"; 22 | Write-Host; 23 | Write-Host " 1 - Certificate Authority (CA) - Equivalent to a certificate from GoDaddy or Verisign but used for development"; 24 | Write-Host " and testing."; 25 | Write-Host " 2 - SSL Server Certificate - Handle SSL on the server. This requires a Certificate Authority (CA) Certificate"; 26 | Write-Host " private and public key file."; 27 | Write-Host " 3 - Client Certificate - Can be used for client certificate authentication. This requires a Certificate"; 28 | Write-Host " Authority (CA) Certificate private and public key file."; 29 | Write-Host; 30 | $certificateType = Read-Host; 31 | Write-Host; 32 | } 33 | while (($certificateType -ne '1') -And ($certificateType -ne '2') -And ($certificateType -ne '3')) 34 | 35 | do 36 | { 37 | Write-Host "Certificate name?"; 38 | $certificateName = Read-Host; 39 | Write-Host; 40 | } 41 | while (!$certificateName) 42 | 43 | if ($certificateType -eq '1' -Or $certificateType -eq '3') 44 | { 45 | $subject = "CN=$certificateName"; 46 | 47 | Write-Host "Organizational unit name e.g. Dev (Optional)?"; 48 | $organizationalUnitName = Read-Host; 49 | Write-Host; 50 | if ($organizationalUnitName) 51 | { 52 | $subject = "$subject,OU=$organizationalUnitName"; 53 | 54 | } 55 | 56 | Write-Host "Organization name e.g. Microsoft (Optional)?"; 57 | $organizationName = Read-Host; 58 | Write-Host; 59 | if ($organizationName) 60 | { 61 | $subject = "$subject,O=$organizationName"; 62 | } 63 | 64 | Write-Host "Locality e.g. San Francisco (Optional)?"; 65 | $localityName = Read-Host; 66 | Write-Host; 67 | if ($localityName) 68 | { 69 | $subject = "$subject,L=$localityName"; 70 | } 71 | 72 | Write-Host "State or province e.g. CA (Optional)?"; 73 | $stateOrProvinceName = Read-Host; 74 | Write-Host; 75 | if ($stateOrProvinceName) 76 | { 77 | $subject = "$subject,S=$stateOrProvinceName"; 78 | } 79 | 80 | Write-Host "Country e.g. US (Optional)?"; 81 | $countryName = Read-Host; 82 | Write-Host; 83 | if ($countryName) 84 | { 85 | $subject = "$subject,C=$countryName"; 86 | } 87 | } 88 | elseif ($certificateType -eq '2') 89 | { 90 | do 91 | { 92 | Write-Host "Domain name e.g. example.com, www.example.com or *.example.com?"; 93 | $domainName = Read-Host; 94 | Write-Host; 95 | } 96 | while (!$domainName) 97 | $subject = "CN=$domainName"; 98 | } 99 | 100 | if ($certificateType -eq '2' -Or $certificateType -eq '3') 101 | { 102 | do 103 | { 104 | Write-Host "Issuer Certificate Authority (CA) private key file path e.g. C:\key.pvk ?"; 105 | $issuerPvk = Read-Host; 106 | Write-Host; 107 | } 108 | while (!$issuerPvk) 109 | 110 | do 111 | { 112 | Write-Host "Issuer Certificate Authority (CA) public key file path e.g. C:\key.cer ?"; 113 | $issuerCer = Read-Host; 114 | Write-Host; 115 | } 116 | while (!$issuerCer) 117 | 118 | Write-Host "Certificate start date e.g. 01/01/2014 (Optional - Leave blank for yesterdays date)?"; 119 | $startDate = Read-Host; 120 | Write-Host; 121 | if (!$startDate) 122 | { 123 | $startDate = (get-date).AddDays(-1).ToString("MM/dd/yyyy") 124 | } 125 | 126 | Write-Host "Certificate end date e.g. 01/01/2100 (Optional - Leave blank for one hundred years in the future)?"; 127 | $endDate = Read-Host; 128 | Write-Host; 129 | if (!$endDate) 130 | { 131 | $endDate = (get-date).AddYears(100).ToString("MM/dd/yyyy") 132 | } 133 | } 134 | 135 | Write-Host "Signature algorithm e.g. MD5, SHA1, SHA256, SHA384, SHA512 (Optional - defaults to SHA512)?"; 136 | $signatureAlgorithm = Read-Host; 137 | Write-Host; 138 | if (!$signatureAlgorithm) 139 | { 140 | $signatureAlgorithm = "SHA512"; 141 | } 142 | 143 | Write-Host "Key length e.g. 4096 (Optional - defaults to 4096)?"; 144 | $keyLength = Read-Host; 145 | Write-Host; 146 | if (!$keyLength) 147 | { 148 | $keyLength = "4096"; 149 | } 150 | 151 | do 152 | { 153 | do 154 | { 155 | Write-Host "Password for the PKCS (.pfx file), not to be confused with the private key password?"; 156 | $password = Read-Host; 157 | Write-Host; 158 | } 159 | while (!$password) 160 | 161 | Write-Host "Confirm password"; 162 | $confirmPassword = Read-Host; 163 | Write-Host; 164 | } 165 | while (!$confirmPassword -And ($password -ne $confirmPassword)) 166 | 167 | try 168 | { 169 | if ($certificateType -eq '1') 170 | { 171 | Write-Host "Making Certificate Authority (CA) Certificate"; 172 | Write-Host " Name: $certificateName"; 173 | Write-Host "Subject: $subject"; 174 | Write-Host; 175 | 176 | Write-Host "$makecert -n `"$subject`" -r -pe -a $signatureAlgorithm -len $keyLength -cy authority -sv `"$certificateName.pvk`" `"$certificateName.cer`""; 177 | & $makecert -n $subject -r -pe -a $signatureAlgorithm -len $keyLength -cy authority -sv "$certificateName.pvk" "$certificateName.cer"; 178 | } 179 | elseif ($certificateType -eq '2') 180 | { 181 | Write-Host "Making SSL Server Certificate"; 182 | Write-Host " Name: $certificateName"; 183 | Write-Host "Subject: $subject"; 184 | Write-Host; 185 | 186 | Write-Host "$makecert -n `"$subject`" -iv $issuerPvk -ic $issuerCer -pe -a $signatureAlgorithm -len $keyLength -b $startDate -e $endDate -sky exchange -eku 1.3.6.1.5.5.7.3.1 -sv `"$certificateName.pvk`" `"$certificateName.cer`""; 187 | & $makecert -n $subject -iv $issuerPvk -ic $issuerCer -pe -a $signatureAlgorithm -len $keyLength -b $startDate -e $endDate -sky exchange -eku 1.3.6.1.5.5.7.3.1 -sv "$certificateName.pvk" "$certificateName.cer"; 188 | } 189 | elseif ($certificateType -eq '3') 190 | { 191 | Write-Host "Making Client Certificate"; 192 | Write-Host " Name: $certificateName"; 193 | Write-Host "Subject: $subject"; 194 | Write-Host; 195 | 196 | Write-Host "$makecert -n `"$subject`" -iv $issuerPvk -ic $issuerCer -pe -a $signatureAlgorithm -len $keyLength -b $startDate -e $endDate -sky exchange -eku 1.3.6.1.5.5.7.3.2 -sv `"$certificateName.pvk`" `"$certificateName.cer`""; 197 | & $makecert -n $subject -iv $issuerPvk -ic $issuerCer -pe -a $signatureAlgorithm -len $keyLength -b $startDate -e $endDate -sky exchange -eku 1.3.6.1.5.5.7.3.2 -sv "$certificateName.pvk" "$certificateName.cer"; 198 | } 199 | 200 | Write-Host "$pvk2pfx -pvk `"$certificateName.pvk`" -spc `"$certificateName.cer`" -pfx `"$certificateName.pfx`" -po $password"; 201 | & $pvk2pfx -pvk "$certificateName.pvk" -spc "$certificateName.cer" -pfx "$certificateName.pfx" -po $password; 202 | } 203 | catch 204 | { 205 | Write-Host "makecert.exe or pvk2pfx.exe was not found. Looked in these locations: $makecert $pvk2pfx"; 206 | Write-Host; 207 | } 208 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MakeCertificate 2 | 3 | Makes certificate files by answering a few simple questions. Read [this](http://www.jayway.com/2014/09/03/creating-self-signed-certificates-with-makecert-exe-for-development/) if you want to learn more about how to create certificates. 4 | 5 | ![Make Certificate Screenshot](Screenshot.png) 6 | 7 | # Author 8 | 9 | Muhammad Rehan Saeed 10 | [RehanSaeed.com](http://RehanSaeed.com) 11 | [@RehanSaeedUK](https://twitter.com/rehansaeeduk) 12 | -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RehanSaeed/MakeCertificate/0630aae5a5ee778f7d68e40821220a6e5094d8b7/Screenshot.png --------------------------------------------------------------------------------