github / github/smimesign

Show smartcard token's labels and certs' key usage

Aperta
#101 2 commenti 3 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
657
Fork
154
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Please consider exposing the label such as "Certificate For Digital Signature" and the key usage ("Digital Signature" and "Non Repudiation"). My PIV token has multiple certificates on it, one of which for the purpose of making signatures. One certificate has the usage of "Key Encipherment" and is inappropriate to use for any signing operations. I cannot currently distinguish between my certificates using the output of `smimesign --list-keys`.

It may also make sense to filter out any keys that do not have the "Digital Signature" key usage. (This isn't enough alone, 3 of my 4 keys have this usage.) This setting could be optional.

1. Add a `Usages:` section to the ` --list-keys` output. This information is available in the `.KeyUsage` `.ExtKeyUsage` properties of the `ident.Certificate()`.

2. Add the "label" of each certificate on the token to the output. This information is not available in the certificate itself, it will need to be added to the platform specific `certstore` code. On macOS it is available in the `labl` attribute of the identity (test with the command line comand:`security export-smartcard -t identities`).

As a workaround, I'm currently using `pkcs11-tool` to list the certificates with labels, then matching it's certificate serial to the output of `smimesign --list-keys`:
```
$ pkcs11-tool --list-objects --type cert
Using slot 0 with a present token (0x0)
Certificate Object; type = X.509 cert
label: Certificate for PIV Authentication
subject: [REDACTED]
ID: 01
Certificate Object; type = X.509 cert
label: Certificate for Digital Signature
subject: [REDACTED]
ID: 02
Certificate Object; type = X.509 cert
label: Certificate for Key Management
subject: [REDACTED]
ID: 03
Certificate Object; type = X.509 cert
label: Certificate for Card Authentication
subject: [REDACTED]
ID: 04
# Pick a key's ID based on it's label. Then get it's serial:
$ pkcs11-tool --read-object --type cert --id 02 | openssl x509 -inform DER -noout -serial
Using slot 0 with a present token (0x0)
serial=12345678
# Match the desired serial to an smimesign key ID:
$ smimesign --list-keys
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dall'output di `smimesign --list-keys` e dalle proprietà di `ident.Certificate()` per `.KeyUsage` e `.ExtKeyUsage`. Segui il codice `certstore` specifico della piattaforma, verificando le etichette delle identità macOS tramite `security export-smartcard -t identities`. Il lavoro è completato quando l'elenco espone gli utilizzi dei certificati e le etichette dei token, con qualsiasi comportamento di filtraggio definito e verificato rispetto ai certificati smartcard.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go
Ambito
cli, security
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.