Returns a bitfield containing the keyUsage flags.
VB6/VBA
Debug.Print "Testing X509_KeyUsageFlags ..." Dim nRet As Long Dim strCertName As String strCertName = "CarlRSASelf.cer" nRet = X509_KeyUsageFlags(strCertName) ' Show the result as a hex number Debug.Print "keyUsage flags are (0x" & Hex(nRet) & "):" ' Check all the keyUsage flags in turn If (nRet And PKI_X509_KEYUSAGE_DIGITALSIGNATURE) <> 0 Then Debug.Print "digitalSignature" If (nRet And PKI_X509_KEYUSAGE_NONREPUDIATION) <> 0 Then Debug.Print "nonRepudiation" If (nRet And PKI_X509_KEYUSAGE_KEYENCIPHERMENT) <> 0 Then Debug.Print "keyEncipherment" If (nRet And PKI_X509_KEYUSAGE_DATAENCIPHERMENT) <> 0 Then Debug.Print "dataEncipherment" If (nRet And PKI_X509_KEYUSAGE_KEYAGREEMENT) <> 0 Then Debug.Print "keyAgreement" If (nRet And PKI_X509_KEYUSAGE_KEYCERTSIGN) <> 0 Then Debug.Print "keyCertSign" If (nRet And PKI_X509_KEYUSAGE_CRLSIGN) <> 0 Then Debug.Print "cRLSign" If (nRet And PKI_X509_KEYUSAGE_ENCIPHERONLY) <> 0 Then Debug.Print "encipherOnly" If (nRet And PKI_X509_KEYUSAGE_DECIPHERONLY) <> 0 Then Debug.Print "decipherOnly"
Output
Testing X509_KeyUsageFlags ... keyUsage flags are (0x61): digitalSignature keyCertSign cRLSign
VB.NET
Console.WriteLine("Testing X509_KeyUsageFlags ...")
Dim nRet As Integer
Dim strCertName As String
strCertName = "CarlRSASelf.cer"
nRet = X509.KeyUsageFlags(strCertName)
' Show the result as a hex number
Console.WriteLine("keyUsage flags are (0x{0:X}):", nRet)
' Check all the keyUsage flags in turn
If (nRet And X509.KeyUsageOptions.DigitalSignature) <> 0 Then Console.WriteLine("digitalSignature")
If (nRet And X509.KeyUsageOptions.NonRepudiation) <> 0 Then Console.WriteLine("nonRepudiation")
If (nRet And X509.KeyUsageOptions.KeyEncipherment) <> 0 Then Console.WriteLine("keyEncipherment")
If (nRet And X509.KeyUsageOptions.DataEncipherment) <> 0 Then Console.WriteLine("dataEncipherment")
If (nRet And X509.KeyUsageOptions.KeyAgreement) <> 0 Then Console.WriteLine("keyAgreement")
If (nRet And X509.KeyUsageOptions.KeyCertSign) <> 0 Then Console.WriteLine("keyCertSign")
If (nRet And X509.KeyUsageOptions.CrlSign) <> 0 Then Console.WriteLine("cRLSign")
If (nRet And X509.KeyUsageOptions.EncipherOnly) <> 0 Then Console.WriteLine("encipherOnly")
If (nRet And X509.KeyUsageOptions.DecipherOnly) <> 0 Then Console.WriteLine("decipherOnly")
[Contents]