S.l.e!ep.¢%

像打了激速一样,以四倍的速度运转,开心的工作
简单、开放、平等的公司文化;尊重个性、自由与个人价值;
posts - 1098, comments - 335, trackbacks - 0, articles - 1
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Application crashes when trying to access X509 Certificate Extension returned by X509_get_ext method
by Sanjay Bhat

Google me that
 REPLY TO AUTHOR  
   Google me that
 REPLY TO GROUP  
 

 

--------------------------------------------------------------------------------

 

 


Hi,

Our application running in windows 2008 64-bit platform crashes when we try to access the data member of X509_EXTENSION returned by X509_get_ext().

We are using  0.9.8d version of openssl compiled for windows 64 bit platform.

We are clueless why this is happening and are badly stuck with this. Please help us.

Here is the code snippet of our application with the point of crash in bold :

BOOL GetX509ObjectString(X509 *Certificate, unsigned char *ASN1, unsigned char *Short, unsigned char *Description, unsigned char *Buffer, unsigned long BufSize)
{
    X509_EXTENSION      *Extension;
    int                 nid;
    int                 Position;
    ASN1_STRING         *Value;
    unsigned char       *OrgPtr;

    if (!Buffer) {
        return(FALSE);
    }
    Buffer[0]='\0';

    nid = OBJ_create(ASN1, Short, Description);
    Position=X509_get_ext_by_NID(Certificate, nid, -1);
    if (Position==-1) {
        return(FALSE);
    }
    
Extension=X509_get_ext(Certificate, Position);
  if (!Extension) {
        return(FALSE);
    }

    /* The M_d2i function alters the pointer, so keep a copy */
    OrgPtr=Extension->value->data; //This is the point of crash. Referencing data member seems to be causing the crash
    Value=M_d2i_ASN1_IA5STRING(NULL, &(Extension->value->data), Extension->value->length);
    Extension->value->data=OrgPtr;
    strncpy(Buffer, Value->data, min(Value->length+1, BufSize));
    Buffer[min(Value->length+1, BufSize)-1]='\0';
    ASN1_STRING_free(Value);

    return(TRUE);
}

Appreciate any kind of help on this is greatly appreciated.

Thanks & Regards,
Sanjay.

 


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理