Validates a certificate path.
VB6/VBA
Debug.Print "Testing X509_ValidatePath ..." Dim nRet As Long Dim strP7cFile As String Dim strTrustedCert As String Dim strCertList As String ' A p7c "certs-only" file which includes a self-signed cert strP7cFile = "testcerts1.p7c" nRet = X509_ValidatePath(strP7cFile, "", 0) Debug.Print "X509_ValidatePath returns " & nRet & " (expected 0)" ' Same again but specify the trusted root cert ' (which is the same as the self-signed cert in the p7c file) strP7cFile = "testcerts1.p7c" strTrustedCert = "testcert00.cer" nRet = X509_ValidatePath(strP7cFile, strTrustedCert, 0) Debug.Print "X509_ValidatePath returns " & nRet & " (expected 0)" ' Specify a cert list - testcert00.cer is the self-signed cert strCertList = "testcert00.cer;testcert03.cer;testcert01.cer;testcert02.cer" nRet = X509_ValidatePath(strCertList, "", 0) Debug.Print "X509_ValidatePath returns " & nRet & " (expected 0)" ' Same again but specify the trusted root cert (this time it is not in the list) strCertList = "testcert01.cer;testcert02.cer;testcert03.cer" strTrustedCert = "testcert00.cer" nRet = X509_ValidatePath(strCertList, strTrustedCert, 0) Debug.Print "X509_ValidatePath returns " & nRet & " (expected 0)"
Output
Testing X509_ValidatePath ... X509_ValidatePath returns 0 (expected 0) X509_ValidatePath returns 0 (expected 0) X509_ValidatePath returns 0 (expected 0) X509_ValidatePath returns 0 (expected 0)
VB.NET
Console.WriteLine("Testing X509_ValidatePath ...")
Dim nRet As Integer
Dim strP7cFile As String
Dim strTrustedCert As String
Dim strCertList As String
' A p7c "certs-only" file which includes a self-signed cert
strP7cFile = "testcerts1.p7c"
nRet = X509.ValidatePath(strP7cFile, "", False)
Console.WriteLine("X509_ValidatePath returns " & nRet & " (expected 0)")
' Same again but specify the trusted root cert
' (which is the same as the self-signed cert in the p7c file)
strP7cFile = "testcerts1.p7c"
strTrustedCert = "testcert00.cer"
nRet = X509.ValidatePath(strP7cFile, strTrustedCert, False)
Console.WriteLine("X509_ValidatePath returns " & nRet & " (expected 0)")
' Specify a cert list - testcert00.cer is the self-signed cert
strCertList = "testcert00.cer;testcert03.cer;testcert01.cer;testcert02.cer"
nRet = X509.ValidatePath(strCertList, "", False)
Console.WriteLine("X509_ValidatePath returns " & nRet & " (expected 0)")
' Same again but specify the trusted root cert (this time it is not in the list)
strCertList = "testcert01.cer;testcert02.cer;testcert03.cer"
strTrustedCert = "testcert00.cer"
nRet = X509.ValidatePath(strCertList, strTrustedCert, False)
Console.WriteLine("X509_ValidatePath returns " & nRet & " (expected 0)")
[Contents]