这是与电子证书交互时使用的命令参考。
openssl rsa -check -text -in privateKey.key
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl sha1
openssl rsa -noout -modulus -in privateKey.key | openssl sha256
openssl rsa -noout -modulus -in privateKey.key | openssl sha512
openssl rsa -aes256 -in privateKey.key -out newPrivateKey.key
openssl ecparam -list_curves
openssl ecparam -name secp521r1 -genkey -noout -out privateKey.key
openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl x509 -noout -modulus -in certificate.crt | openssl sha1
openssl x509 -noout -modulus -in certificate.crt | openssl sha256
openssl x509 -noout -modulus -in certificate.crt | openssl sha512
或者,也可以这样:
openssl x509 -noout -fingerprint -in certificate.crt
openssl x509 -noout -fingerprint -sha256 -in certificate.crt
openssl x509 -in certificate.crt -noout -text|more
openssl x509 -noout -subject certificate.crt
openssl x509 -noout -issuer certificate.crt
openssl x509 -noout -dates certificate.crt
echo | openssl s_client -servername www.openssl.org -connect \
www.openssl.org:443 2>/dev/null | openssl x509 -noout -text|more
echo | openssl s_client -servername imap.arcor.de -connect \
imap.arcor.de:993 2>/dev/null | openssl x509 -noout -text|more
正常
openssl verify -verbose -x509_strict -CAfile \
issuer.crt Test\ Haeschen\ 1.crt
结果:
Test Haeschen 1.crt: OK
损坏 (例如)
openssl verify -verbose -x509_strict -CAfile \
issuer.crt Test\ Haeschen\ 1_corrupted.crt
结果:
C = DE, ST = Thueringen, L = Rudolstadt, O = Damaschkestr. 11, OU = Arbeitszimmer, CN = Test Haeschen 1
error 7 at 0 depth lookup: certificate signature failure
error Test Haeschen 1_corrupted.crt: verification failed
40270500477F0000:error:0200008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding:../crypto/rsa/rsa_pk1.c:75:
40270500477F0000:error:02000072:rsa routines:rsa_ossl_public_decrypt:padding check failed:../crypto/rsa/rsa_ossl.c:598:
40270500477F0000:error:1C880004:Provider routines:rsa_verify:RSA lib:../providers/implementations/signature/rsa_sig.c:774:
40270500477F0000:error:06880006:asn1 encoding routines:ASN1_item_verify_ctx:EVP lib:../crypto/asn1/a_verify.c:217:
openssl crl -inform DER -noout -text -in crl/cacrl.der
openssl crl -inform PEM -noout -text -in crl/cacrl.pem
openssl ts -query -in query.tsq -text
openssl ts -reply -in reply.tsr -text
openssl ts -verify -in reply.tsr -data data.dat -CAfile chain.pem
openssl ts -reply -in reply.tsr -token_out -out token.tk
openssl pkcs7 -inform DER -in token.tk -print_certs -noout -text
消息被篡改(返回码 4):
Verification failure
140485684135232:error:2E09A09E:CMS routines:CMS_SignerInfo_verify_content:verification failure:../crypto/cms/cms_sd.c:847:
140485684135232:error:2E09D06D:CMS routines:CMS_verify:content verify error:../crypto/cms/cms_smime.c:393:
消息签名不受信任(返回码 4):
Verification failure
140146111432000:error:2E099064:CMS routines:cms_signerinfo_verify_cert:certificate verify error:../crypto/cms/cms_smime.c:252:Verify error:unable to get local issuer certificate
消息未签名(返回码 2):
Error reading S/MIME message
140701208487232:error:0D0D40CD:asn1 encoding routines:SMIME_read_ASN1:invalid mime type:../crypto/asn1/asn_mime.c:469:type: multipart/alternative
验证成功(返回码 0):
Verification successful
openssl cms -verify -in some_email_message.eml
openssl cms -verify -in some_email_message \
-CAfile trust_anchor-crt
注意:保存数字身份的 P12 文件必须是 pem 编码的!(见上文)
openssl cms -decrypt -out decrypted_email_message \
-inkey p12.pem -in some_encrypted_email_message