@@ -876,7 +876,7 @@ def show_certificate_authority(name=None, pem=False):
876
876
print ("Certificate Authorities:" )
877
877
print (tabulate .tabulate (data , headers ))
878
878
879
- def show_certificate (name = None , pem = False ):
879
+ def show_certificate (name = None , pem = False , fingerprint_hash = None ):
880
880
headers = ['Name' , 'Type' , 'Subject CN' , 'Issuer CN' , 'Issued' , 'Expiry' , 'Revoked' , 'Private Key' , 'CA Present' ]
881
881
data = []
882
882
certs = get_config_certificate ()
@@ -897,6 +897,9 @@ def show_certificate(name=None, pem=False):
897
897
if name and pem :
898
898
print (encode_certificate (cert ))
899
899
return
900
+ elif name and fingerprint_hash :
901
+ print (get_certificate_fingerprint (cert , fingerprint_hash ))
902
+ return
900
903
901
904
ca_name = get_certificate_ca (cert , ca_certs )
902
905
cert_subject_cn = cert .subject .rfc4514_string ().split ("," )[0 ]
@@ -923,12 +926,6 @@ def show_certificate(name=None, pem=False):
923
926
print ("Certificates:" )
924
927
print (tabulate .tabulate (data , headers ))
925
928
926
- def show_certificate_fingerprint (name , hash ):
927
- cert = get_config_certificate (name = name )
928
- cert = load_certificate (cert ['certificate' ])
929
-
930
- print (get_certificate_fingerprint (cert , hash ))
931
-
932
929
def show_crl (name = None , pem = False ):
933
930
headers = ['CA Name' , 'Updated' , 'Revokes' ]
934
931
data = []
@@ -1074,7 +1071,7 @@ def show_crl(name=None, pem=False):
1074
1071
if args .fingerprint is None :
1075
1072
show_certificate (None if args .certificate == 'all' else args .certificate , args .pem )
1076
1073
else :
1077
- show_certificate_fingerprint (args .certificate , args .fingerprint )
1074
+ show_certificate (args .certificate , fingerprint_hash = args .fingerprint )
1078
1075
elif args .crl :
1079
1076
show_crl (None if args .crl == 'all' else args .crl , args .pem )
1080
1077
else :
0 commit comments