Dear

I found a function X509_NAME_get_text_by_NID().
I think it's OK.

Thanks

>I'm trying to make a simple https client.
>This client application uses openssl-0.9.4 
>on Sun SPARC Solaris (SunOS 5.5.1) machine.
>
>For checking server's common name,I'm trying 
>to implement as follows:
>
>       /**/
>       int host_rtn=0;
>       struct hostent host;
>       char host_real[BUFSIZ];
>       char CommonName[BUFSIZ];
>       char *ConnectHost;
>       X509 *x509_info=NULL;
>               :
>       /* Get Host Address and Full Name */
>       gethostbyname_r(hostname,&host,host_real,sizeof(host_real),&host_rtn);
>       if(host_rtn!=0){
>               fprintf(stderr,"gethostbyname\n");
>               return -1;
>       }
>       ConnectHost=host.h_name;
>               :
>       /* Get Certification Information */
>       x509_info=SSL_get_peer_certificate(con);
>
>       /* Common Name Check */
>       strcpy(CommonName,strstr(x509_info->name,"CN=")+3);
>       strtok_r(CommonName,"/\r\n",&strtok_holder);
>       if(strcasecmp(ConnectHost,CommonName)!=0){
>               fprintf(stderr,"HostName differ from CommonName\n");
>               return -1;
>       }
>
>But I think it isn't best method.
>Is there any function to get server's common name?
>Please teach me.
>
>Thanks.
>                                                       Takenori Yoshimatsu
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to