Self-Signed Certificate

Creating a self signed certificate using openssl

openssl genrsa -out key.pem 2048
openssl req -new -sha256 -key key.pem -out csr.csr
openssl req -x509 -sha256 -days 365 -key key.pem -in csr.csr -out cert.pem
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem

Standalone Script

openssl genrsa -out server.key 2048
openssl req -new -sha256 -key server.key -out server.csr \
    -subj "/C=BD/ST=Dhaka/L=Dhaka/O=Bangladesh Computer Council/OU=Certificate Authority/CN=flask-bcc.gov.bd/[email protected]"
openssl req -x509 -sha256 -days 365 -key server.key -in server.csr -out server.crt
openssl pkcs12 -export -out cert.pfx -inkey server.key -in server.crt -password 123456

EC

# 1. Generate EC private key (secp256r1 / prime256v1)
openssl ecparam -name prime256v1 -genkey -noout -out key.pem

# 2. Create a self-signed certificate (or sign a CSR with your CA)
openssl req -new -x509 -key key.pem -out cert.pem -days 3650 \
  -subj "/C=BD/O=Bangladesh Computer Council/CN=BCC CA G3 PKI"

# 3. Export to PKCS12 using modern PBE algorithms BC understands
openssl pkcs12 -export \
  -inkey key.pem -in cert.pem \
  -out ec-cert.p12 -name 1 \
  -passout pass:123456 \
  -keypbe AES-256-CBC -certpbe AES-256-CBC