Microsoft Docs

MakeCert

Overview

MakeCert is a command‑line utility used to create self‑signed X.509 certificates for development and testing. It is part of the Windows SDK and can generate certificates with custom extensions, key lengths, and validity periods.

Download

Download MakeCert (ZIP)

Syntax

makecert [-r] [-a algorithm] [-b date] [-e date] [-n "CN=name"] [-ss store] [-sr location] [-sk keyname] [-sp provider] [-sy provider_type] [-len keylength] [-sky keytype] [-sv filename] [-sv filename.pvk] [-iv filename] [-ic filename] [-ir location] [-is store] [-sr location] [-sky keytype] [options] outputcert.cer

Common Parameters

ParameterDescription
-rCreates a self‑signed certificate.
-a algorithmHash algorithm (SHA1, SHA256, SHA384, SHA512). Default is SHA1.
-b dateStart date (MM/DD/YYYY). Defaults to today.
-e dateExpiration date (MM/DD/YYYY).
-n "CN=name"Subject name. Example: "CN=MyTestCert".
-ss storeCertificate store name (e.g., My, Root).
-sr locationStore location: CurrentUser or LocalMachine.
-sk keynameKey container name.
-sp providerCrypto provider name (default: "Microsoft RSA SChannel Cryptographic Provider").
-sy provider_typeProvider type (e.g., 12 for RSA).
-len keylengthKey length in bits (default 2048).
-sky keytypeKey type: exchange or signature.
-sv pvkfileExports the private key to a .pvk file.
-iv pfxfileImports a .pvk file when creating a .pfx.

Examples

1. Create a self‑signed certificate for localhost

makecert -r -pe -n "CN=localhost" -b 01/01/2025 -e 01/01/2035 -sky exchange -ss My -len 2048 localhost.cer

2. Create a certificate with a private key (.pvk) and export to .pfx

makecert -r -pe -n "CN=MyApp" -ss My -len 4096 -sv myapp.pvk myapp.cer
pvk2pfx -pvk myapp.pvk -spc myapp.cer -pfx myapp.pfx

Related Tools