about random numbers.
I use sun 5.6 and there are ports of the linux /dev/urandom to sun 5.6
OR you can also use... cpu info to get a fairly random number.
This method will allow your code to port to other sun boxes without
having to install the /dev/urandom
prusage_t prusage;
prstatus_t prstatus;
prpsinfo_t prpsinfo;
int _fd;
// Processor status
ioctl(_fd, PIOCSTATUS, &prstatus);
// Processor info
ioctl(_fd, PIOCPSINFO, &prpsinfo);
char **ap = prpsinfo.pr_argv;
char **ep = prpsinfo.pr_envp;
// Processor usage
ioctl(_fd, PIOCUSAGE, &prusage);
I'm no mathmatician and if this method is subpar or if there is a better
way I'm all ears.
--ian
-----Original Message-----
From: Jason Scharlach [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 19, 2001 2:41 PM
To: [EMAIL PROTECTED]
Subject: Re: SunOS 5.6 probs?
Lutz
The openssl application does work just fine. I figured I would ask
here before I went and recompiled the debug on.
As for the not checking of return codes, I actually do have checks in
my code but I removed them to simplify what I was posting. Thanks for
the catch on ERR_print_errors! I've recompiled and I'm actually getting
a somewhat useful error now.
18686:error:24064064:random number generator:SSLEAY_RAND_BYTES:PRNG not
seeded:md_rand.c:474:You need to read the OpenSSL FAQ,
http://www.openssl.org/support/faq.html
It's a problem with random number generator. SunOS doesn't come with
any easy way of generating random number (that I know of) and this has
caused me issues in the past. I'm going to send out another post asking
about this issue. Thanks!
Jason
Lutz Jaenicke wrote:
>
> On Fri, Jan 19, 2001 at 04:05:19PM -0500, Jason Scharlach wrote:
> > Has anyone else had any issues with SunOS and openSSL?
>
> I don't have SunOS, but I also do not remember having seen reports about
> special problems with SunOS...
> Does the openssl application work? You can use "openssl s_client ..."
> to perform the connection test.
>
> > Any help/advice would be greatly appriciated!
> Compile with "-g", call your favorite debugger and check out why the
> segmentation fault occured.
>
> Let's discuss your code:
>
> > int main( void )
> > {
> > int sock;
> > struct sockaddr_in sSockAddr;
> > struct hostent *spHostEnt;
> >
> > SSL_CTX *ctx = NULL;
> > SSL_METHOD *meth = NULL;
> > SSL *ssl = NULL;
> >
> >
> > sSockAddr.sin_family = AF_INET;
> > sSockAddr.sin_port = htons( 443 );
> >
> > spHostEnt = gethostbyname( "www.csi.ca" );
>
> Here you do not check the return value. gethostbyname might return NULL
> because of a failure.
>
> > memcpy( &(sSockAddr.sin_addr.s_addr),
> > spHostEnt->h_addr_list[0],
> > spHostEnt->h_length );
> >
> > sock = socket( AF_INET, SOCK_STREAM, 0 );
> > connect( sock, (struct sockaddr *)&sSockAddr, sizeof( sSockAddr ));
>
> Here you do not check sock [socket() might fail] and you do not check the
> return value of connect() for failure.
>
> > SSLeay_add_ssl_algorithms();
> > meth = SSLv2_client_method();
> > SSL_load_error_strings();
> > ctx = SSL_CTX_new(meth);
> >
> > ssl = SSL_new( ctx );
> >
> > SSL_set_fd( ssl, sock );
> > ERR_print_errors();
>
> Of course, you did not check whether ctx and ssl have been successfully
> created. You do not check whether SSL_set_fd() was successfull.
> (I don't know whether this applies here, but at least some of the
> OpenSSL functions are "NULL proof": they simply return 0 for failure
> but do not set an error message because they suppose "nothing to be
done".)
>
> > printf( "SSL_connect: %d\n", SSL_connect( ssl ) );
> > ERR_print_errors();
>
> Aha, and here we go: ERR_print_errors() is actually called as:
> void ERR_print_errors(BIO *bp);
> with bp being the BIO to which the errors shall be reported. You do not
> specify bp, so of course ERR_print_errors() will try to put the error
message
> to an undefined location.
> Any good compiler should have warned you, that you did violate the
function
> prototype by not supplying "one argument of type BIO *".
> (Actually the other ERR_print_errors() call only did not segfault because
> nothing was to be reported.)
>
> You probably want to use ERR_print_errors_fp(stderr) (or set up the BIO
> for the error messages).
>
> Best regards,
> Lutz
> --
> Lutz Jaenicke [EMAIL PROTECTED]
> BTU Cottbus http://www.aet.TU-Cottbus.DE/personen/jaenicke/
> Lehrstuhl Allgemeine Elektrotechnik Tel. +49 355 69-4129
> Universitaetsplatz 3-4, D-03044 Cottbus Fax. +49 355 69-4153
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> User Support Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]