GetCertificate Method
GetCertificate(Byte)
Get the certificate in the given slot.
public X509Certificate2 GetCertificate(byte slotNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slotNumber | The slot containing the requested cert. |
Returns
The cert residing in the slot specified.
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The slot specified is not valid for getting a certificate. |
System.InvalidOperationException | The slot did not contain a cert, or the YubiKey had some other error, such as unreliable connection. |
Remarks
After obtaining a cert, you can install it into the slot containing the associated private key (ImportCertificate(Byte, X509Certificate2)). Later on, when you need the cert (e.g. to send it along with a signed message), call this method to retrieve it.
It is not necessary to authenticate the management key nor verify the PIN in order to obtain a certificate.
If the slotNumber
given is for a slot that does not hold
asymmetric keys, or if there is no cert in the slot, this method will
throw an exception.
If you want to get the attestation cert, do not use this method, call
GetAttestationCertificate(). If you call this method with
slot number 0xF9
(PivSlot.Attestation
) it will throw an
exception.