RE: segmentation fault printing x509 attributes

2010-11-29 Thread Ignacio Amoeiro Bosch
Hi,

Thanks for the response, I checked that and the headers match with the
library that im linking.

This is the contents of my make file:

CC = gcc
CP = /bin/cp
RM = rm -f
AUTHN_INCLUDE_DIR =include

OBJS = authn_api.o
DSO  = authn_api.so

GCC_FLAGS= -I$(AUTHN_INCLUDE_DIR) -I/root/openssl/include -c -fPIC -Wall

$(DSO): $(OBJS)
$(CC) -g -shared $(OBJS) /lib/libssl.so.1.0.0
/lib/libcrypto.so.1.0.0 -o $(DSO) -m32
$(OBJS): authn_api.c
$(CC) -g  $(GCC_FLAGS) -o $(OBJS) authn_api.c -m32


Another thing, How can I check that the readed X509 structure its
correct?

Regards

-Mensaje original-
De: owner-openssl-...@openssl.org [mailto:owner-openssl-...@openssl.org]
En nombre de David Schwartz
Enviado el: lunes, 29 de noviembre de 2010 5:36
Para: openssl-dev@openssl.org
Asunto: Re: segmentation fault printing x509 attributes

On 11/28/2010 1:53 AM, Ignacio Amoeiro Bosch wrote:

> The following code Works in a standalone c program, but crash (with a 
> seg fault) using it as a module. The crash occurs at line :
> X509_get_version(x), or any method that uses x

My guess would be that the OpenSSL headers you are compiling with don't
precisely match the library that you are linking to. Functions like
X509_get_version are macros that extract elements of the X509 structure.

DS

__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: segmentation fault printing x509 attributes

2010-11-28 Thread David Schwartz

On 11/28/2010 1:53 AM, Ignacio Amoeiro Bosch wrote:


The following code Works in a standalone c program, but crash (with a
seg fault) using it as a module. The crash occurs at line :
X509_get_version(x), or any method that uses x


My guess would be that the OpenSSL headers you are compiling with don't 
precisely match the library that you are linking to. Functions like 
X509_get_version are macros that extract elements of the X509 structure.


DS

__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


segmentation fault printing x509 attributes

2010-11-28 Thread Ignacio Amoeiro Bosch
 
Hi,

 

I'm developing a custom module for Oracle Access Manager. It needs to read some 
attributes from a certificate. 


The following code Works in a standalone c program, but crash (with a seg 
fault) using it as a module. The crash occurs at line : X509_get_version(x), or 
any method that uses x

 

 

char certificate[]="-BEGIN 
CERTIFICATE-\nMIIF7TCCBNWgAwIBAgIQBP/1hLYXHqFL0JS0tW1F6DANBgkqhkiG9w0BAQUFADBc\nMQswCQYDVQQGEwJFUzEoMCYGA1UECgwfRElSRUNDSU9OIEdFTkVSQUwgREUgTEEg\nUE9MSUNJQTENMAsGA1UECwwERE5JRTEUMBIGA1UEAwwLQUMgRE5JRSAwMDEwHhcN\nMTAwNDIyMTgyNTU1WhcNMTIxMDIyMTgyNTQ4WjB/MQswCQYDVQQGEwJFUzESMBAG\nA1UEBRMJNDQwNDc0OTNEMQ8wDQYDVQQEDAZCRU5JVE8xFTATBgNVBCoMDE1JR1VF\nTCBBTkdFTDE0MDIGA1UEAwwrQkVOSVRPIFRPVkFSLCBNSUdVRUwgQU5HRUwgKEFV\nVEVOVElDQUNJw5NOKTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL7n\nkkMh6u0xNmanPHKYIwXFBiMqtWxy6q19G9lloQ2np41/XpQ73xNhJ3P4VYt7axAt\njNJuFU+yd8034Gj2ul33EFsJW4EV2Mz37foBnbCLU4z9QyJ5YlrAuNTRW+cuBjly\nF+BBw1B5QofYYnMtg9Sur291QgEEC/vA5n2GMGXKRoPA8MP5vbWDSx02jiJxtGOP\nHoB64/D33K8rBbN6f3jXOXbi0A+OHsvZ5apfb1R7a2UzzX7xVX+IRtRi4yM3Q1VR\nw276wjH7P1pf+mDaKLNWEJM4loyi6aj1wGSDC9TsyDNrey+ui04cIfWrwLkfBThj\nuh2wXKK8vP+aAl+8OQECAwEAAaOCAoYwggKCMAwGA1UdEwEB/wQCMAAwDgYDVR0P\nAQH/BAQDAgeAMB0G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1Esif7VP6LeP4H4blhmt8sQbmChYbfXJl1D\nzL37bGl3xY4Zu/DIpWekXqddVyEBtDZjy9AhjcE3tDo5eO9Y9Yx3hZBbty3c3UMq\n2utP8v+jc9f530avKbX8swqXcERjFeH1GHmuA4xhlznM\n-END
 CERTIFICATE-\n";

 

X509 *x = NULL;

BIO *mem =NULL;

FILE *fp;

 

fp = fopen("/tmp/testfilen_fn.txt","a+");

mem = BIO_new_mem_buf((void *)certificate,-1);

 

 

x=PEM_read_bio_X509 (mem,NULL,NULL,NULL);

 

BIO_free(mem);

 

if (x!=NULL){

fprintf(fp,"Version %d\n",(int)X509_get_version(x));

}

 

X509_free(x);

fclose(fp);

 

 

What is wrong?

 

 

Thanks