[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-cryptoapi
Subject:    Re: Where's CertGetNameString?
From:       Jim Krahn <jimk () EXTENDSYS ! COM>
Date:       1998-09-16 17:49:04
[Download RAW message or body]


As you figured out it is documented but not implemented.
Use CertNameToStr as a substitute.
Here is an example:

CString CertGetNameString( CERT_NAME_BLOB *pCertName )
{
   CString name;
   DWORD size = CertNameToStr( X509_ASN_ENCODING, pCertName,
CERT_OID_NAME_STR, NULL, 0 );
   if ( size ) {
      // Get OID Name string
      char *pName = new char[size];
      CertNameToStr( X509_ASN_ENCODING, pCertName, CERT_X500_NAME_STR,
pName, size );
      name = pName;
      delete pName;

      // Extract common name prefix
      char *pNameAttr[] = { "CN=", "OU=", "O=", "E=", NULL };
      int start = -1, end = -1;
      int nameNdx = 0;
      while ( start == -1 && pNameAttr[nameNdx] ) {
         // Look for prefix
         start = name.Find( pNameAttr[nameNdx] );
         if ( start != -1 ) {
            // Skip prefix
            start = start + strlen( pNameAttr[nameNdx] );
            // Names are quoted if they contain a comma
            if ( name.Mid( start, 1 ) == "\"" ) {
               start++;
               end = name.Mid( start ).Find( "\"" );
            }
            else 
               end = name.Mid( start ).Find( "," );
            if ( end == -1 ) 
               name = name.Mid( start );
            else
               name = name.Mid( start, end );
            break;
         }
         nameNdx++;
      }
   }

   return name;
}

Jim

-----Original Message-----
From: Rodrigo Oliveira [mailto:rodrigob@VESTA.COM.BR]
Sent: Monday, September 14, 1998 3:13 PM
To: CryptoAPI@DISCUSS.MICROSOFT.COM
Subject: Where's CertGetNameString?


The MSDN includes documentation on the crypto api function
CertGetNameString, but I really couldn't find it in my wincrypt.h.
Any thoughts?
 

Rodrigo B. de Oliveira, MCSD
Vesta Technologies
Microsoft Solution Provider / Key Partner /  Regional Director 99
Howzitgoin? Interested in Internet development?
Check it out at http://www.vesta.com.br !


 

----------------------------------------------------------------
Users Guide http://www.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

----------------------------------------------------------------
Users Guide http://www.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic