CryptoSys PKI examples VB6 to VB.NET

X509_CertSubjectName

Extracts subject's name from X.509 certificate.

VB6/VBA

Debug.Print "Testing X509_CertSubjectName ..."
Dim nRet As Long
Dim nLen As Long
Dim strCertName As String
Dim strOutput As String
 
strCertName = "AAA010101AAAsd.cer"
nLen = X509_CertIssuerName(strCertName, "", 0, ",", 0)
Debug.Print "X509_CertIssuerName returns " & nLen & " for " & strCertName
strOutput = String(nLen, " ")
nRet = X509_CertIssuerName(strCertName, strOutput, Len(strOutput), ",", 0)
Debug.Print "[" & strOutput & "]"

nLen = X509_CertSubjectName(strCertName, "", 0, ",", 0)
Debug.Print "X509_CertSubjectName returns " & nLen & " for " & strCertName
strOutput = String(nLen, " ")
nRet = X509_CertSubjectName(strCertName, strOutput, Len(strOutput), ",", 0)
Debug.Print "[" & strOutput & "]"

Output

Testing X509_CertSubjectName ...
X509_CertIssuerName returns 149 for AAA010101AAAsd.cer
[L=Ciudad de Mexico,ST=Mexico, D.F.,C=MX,CN=AC de Pruebas SAT,OU=Administración de Seguridad de la Información,O=Servicio de Administración Tributaria]
X509_CertSubjectName returns 157 for AAA010101AAAsd.cer
[2.5.4.45=AAA010101AAA / AAAA010101AAA,2.5.4.5= / AAAA010101HDFRXX00,O=Empresa de Prueba,OU=Sucursal de Prueba,CN=Empresa de Prueba,2.5.4.41=Empresa de Prueba]

VB.NET

Console.WriteLine("Testing X509_CertSubjectName ...")
Dim strCertName As String
Dim strOutput As String

strCertName = "AAA010101AAAsd.cer"
strOutput = X509.CertIssuerName(strCertName, "")
Console.WriteLine("X509.CertIssuerName returns " & strOutput.Length & " for " & strCertName)
Console.WriteLine("[" & strOutput & "]")

strOutput = X509.CertSubjectName(strCertName, "")
Console.WriteLine("X509.CertSubjectName returns " & strOutput.Length & " for " & strCertName)
Console.WriteLine("[" & strOutput & "]")

[Contents]

[HOME]   [NEXT: X509_CertThumb...]

Copyright © 2010-20 D.I. Management Services Pty Ltd. All rights reserved.