Giter Club home page Giter Club logo

hs-crypto's Introduction

OPENSSL生成证书

1、创建一个缺省配置文件<file:ca.cnf>【可选】
[ req ]
default_bits       = 2048
default_keyfile        = privkey.pem
distinguished_name = req_distinguished_name

[ req_distinguished_name ]
countryName                 = Country Name (2 letter code)
countryName_default         = CN
stateOrProvinceName         = State or Province Name (full name)
stateOrProvinceName_default = JiangSu
localityName                = Locality Name (eg, city)
localityName_default        = NanJing
organizationName            = Organization Name (eg, company)
organizationName_default    = Sheld
commonName                  = Common Name (e.g. server FQDN or YOUR name)
commonName_max              = 64
commonName_default          = Ted CA Test
emailAddress           = [email protected]

2、生成证书

2.1 创建私钥privkey.pem

openssl genrsa -out privkey.pem 2048
或者
openssl genpkey -algorithm RSA -out privkey.pem

扩展参数:-des3

2.2 使用cnf配置创建证书申请文件req.pem
openssl req -new -key privkey.pem -out req.pem -config ca.cnf

2.3 创建cer证书
openssl req -x509 -key privkey.pem -out test.cer -config ca.cnf

扩展参数:-days 750

2.4创建pfx证书
openssl pkcs12 -export -in test.cer -inkey privkey.pem -out test.pfx
Export Password:123456

3、查看
私钥
openssl pkey -in privkey.pem -text -noout

证书申请
openssl req -in req.pem -text -verify -noout

cer证书
openssl x509 -in test.cer -noout -text

# 查看证书完整信息
openssl x509 -in test.cer -text -noout

# 查看证书包含的公钥
openssl x509 -in test.cer -pubkey

# 查看哪个 CA 机构签发了证书
openssl x509 -in test.cer -issuer

# 查看证书的有效期
openssl x509 -in test.cer -enddate

pfx
openssl pkcs12 -in test.pfx -info -noout

4、其他
生成公钥
openssl rsa -in privkey.pem -pubout -out pubkey.pem

hs-crypto's People

Stargazers

 avatar

Watchers

James Cloos avatar huangsui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.