Blob Blame History Raw
From 7805bb5c87fcc07e207f4f3e3e3ff82f55f5ff08 Mon Sep 17 00:00:00 2001
From: Dag Heyman <dag@yubico.com>
Date: Mon, 18 Mar 2019 10:22:27 +0100
Subject: [PATCH 1/2] piv: fix piv info for cryptography version < 2.5

---
 ykman/cli/piv.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ykman/cli/piv.py b/ykman/cli/piv.py
index ad17339..7d62a1c 100644
--- a/ykman/cli/piv.py
+++ b/ykman/cli/piv.py
@@ -163,11 +163,12 @@ def info(ctx):
             issuer_dn = cert.issuer.rfc4514_string()
             print_dn = True
         except AttributeError:
+            print_dn = False
             logger.debug('Failed to read DN, falling back to only CNs')
             subject_cn = cert.subject.get_attributes_for_oid(x509.NameOID.COMMON_NAME)
-            subject_cn = subject_cn[0].value if len(cn) > 0 else 'None'
+            subject_cn = subject_cn[0].value if subject_cn else 'None'
             issuer_cn = cert.issuer.get_attributes_for_oid(x509.NameOID.COMMON_NAME)
-            issuer_cn = issuer_cn[0].value if len(cn) > 0 else 'None'
+            issuer_cn = issuer_cn[0].value if issuer_cn else 'None'
         except ValueError as e:
             # Malformed certificates may throw ValueError
             logger.debug('Failed parsing certificate', exc_info=e)

From b3b17714c957ecf50b504a2444d8a361a4bb26be Mon Sep 17 00:00:00 2001
From: Dag Heyman <dag@yubico.com>
Date: Mon, 18 Mar 2019 10:23:18 +0100
Subject: [PATCH 2/2] piv: print algo name in piv info

---
 ykman/cli/piv.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ykman/cli/piv.py b/ykman/cli/piv.py
index 7d62a1c..736a260 100644
--- a/ykman/cli/piv.py
+++ b/ykman/cli/piv.py
@@ -182,7 +182,7 @@ def info(ctx):
         not_after = cert.not_valid_after
 
         # Print out everything
-        click.echo('\tAlgorithm:\t%s' % algo)
+        click.echo('\tAlgorithm:\t%s' % algo.name)
         if print_dn:
             click.echo('\tSubject DN:\t%s' % subject_dn)
             click.echo('\tIssuer DN:\t%s' % issuer_dn)