CryptoSys PKI Pro Manual

X509_TextDumpToString

Dumps details of an X.509 certificate or a X.509 certificate revocation list (CRL) or a PKCS-10 certificate signing request (CSR) to a string.

VBA/VB6 Syntax

Public Declare Function X509_TextDumpToString Lib "diCrPKI.dll" (ByVal strOutput As String, ByVal nOutChars As Long, ByVal strCertFile As String, ByVal nOptions As Long) As Long

nRet = X509_TextDumpToString(strOutput, nOutChars, strCertFile, nOptions)

C/C++ Syntax

long __stdcall X509_TextDumpToString(char *szOutput, long nOutChars, const char *szCertFile, long nOptions);

Parameters

szOutput
[out] String buffer to receive output.
nOutChars
[in] Maximum number of characters to be received.
szCertFile
[in] Name of input file (or its base64 or PEM string representation).
nOptions
[in] option flags:
PKI_X509_LATIN1 to try and convert UTF-8 attribute strings to Latin-1 (for display purposes).
PKI_X509_UTF8 to output attribute strings encoded in UTF-8 (C/C++ only) [New in v20.3]
PKI_X509_LDAP to output the distinguished name in LDAP string representation.
PKI_X509_DECIMAL to output the serial number in decimal format instead of hexadecimal.

Returns (VBA/C)

If successful, the return value is the number of characters in or required for the output string; otherwise it returns a negative error code.

VBA Wrapper Syntax

Public Function x509TextDumpToString (szCertFile As String, Optional nOptions As Long = 0) As String

.NET Equivalent

X509.TextDumpToString Method

C++ (STL) Equivalent

static std::string dipki::X509::TextDumpToString (const std::string &certFile, OutputOpts outOpts=OutputOpts::Default_OutputOpt)

Python Equivalent

static X509.text_dump_tostring(certfile, opts=0)

Remarks

For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length. Specify a zero nOutChars or an empty string for szOutput to find the required length. ANSI C users must add one to this value when allocating memory.

The input file may be a an X.509 certificate, X.509 certificate revocation list (CRL) or PKCS-10 certificate signing request (CSR) and may be a file in binary BER/DER or base64 PEM file format, or may be passed in base64 representation or as a PEM string.

The output string must be long enough to receive the complete output or a SHORT_BUF_ERROR error will result.

Example (VBA core function)

Dim strInputFile As String
Dim strBuffer As String
Dim nChars As Long

strInputFile = "AliceRSASignByCarl.cer"
Debug.Print "File=" & strInputFile
' Query for required length
nChars = X509_TextDumpToString("", 0, strInputFile, PKI_X509_DECIMAL)
Debug.Print "X509_TextDumpToString returns " & nChars
' Dimension output buffer
strBuffer = String(nChars, " ")
nChars = X509_TextDumpToString(strBuffer, Len(strBuffer), strInputFile, PKI_X509_DECIMAL)
Debug.Print strBuffer
File=AliceRSASignByCarl.cer
X509_TextDumpToString returns 1692
X.509 CERTIFICATE
Version: 3
Serial Number:
  93318145165434344057210696409401045936
Issuer:
  CN=CarlRSA
...[cut]...

Example (VBA wrapper function)

Debug.Print x509TextDumpToString("AliceRSASignByCarl.cer")
Debug.Print x509QueryCert("AliceRSASignByCarl.cer", "subjectName")
Debug.Print asn1TextDumpToString("AliceRSASignByCarl.cer")

See Also

X509_QueryCert ASN1_TextDump

[Contents] [Index]

[PREV: X509_TextDump...]   [Contents]   [Index]   
   [NEXT: X509_ValidatePath...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.