Commit ef413a7e authored by Richard Levitte's avatar Richard Levitte
Browse files

Merge of main trunk, no conflicts this time

parent dcd4d341
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ OpenSSL - Frequently Asked Questions
* Why does the linker complain about undefined symbols?
* Where can I get a compiled version of OpenSSL?
* I've compiled a program under Windows and it crashes: why?
* How do I read or write a DER encoded buffer using the ASN1 functions?
* I've tried using <M_some_evil_pkcs12_macro> and I get errors why?
* I've called <some function> and it fails, why?
* I just get a load of numbers for the error output, what do they mean?
@@ -182,6 +183,43 @@ otherwise the conflict will cause a program to crash: typically on the
first BIO related read or write operation.


* How do I read or write a DER encoded buffer using the ASN1 functions?

You have two options. You can either use a memory BIO in conjunction
with the i2d_XXX_bio() or d2i_XXX_bio() functions or you can use the
i2d_XXX(), d2i_XXX() functions directly. Since these are often the
cause of grief here are some code fragments using PKCS7 as an example:

unsigned char *buf, *p;
int len;

len = i2d_PKCS7(p7, NULL);
buf = OPENSSL_Malloc(len); /* or Malloc, error checking omitted */
p = buf;
i2d_PKCS7(p7, &p);

At this point buf contains the len bytes of the DER encoding of
p7.

The opposite assumes we already have len bytes in buf:

unsigned char *p;
p = buf;
p7 = d2i_PKCS7(NULL, &p, len);

At this point p7 contains a valid PKCS7 structure of NULL if an error
occurred. If an error occurred ERR_print_errors(bio) should give more
information.

The reason for the temporary variable 'p' is that the ASN1 functions
increment the passed pointer so it is ready to read or write the next
structure. This is often a cause of problems: without the temporary
variable the buffer pointer is changed to point just after the data
that has been read or written. This may well be uninitialized data
and attempts to free the buffer will have unpredictable results
because it no longer points to the same address.


* I've tried using <M_some_evil_pkcs12_macro> and I get errors why?

This usually happens when you try compiling something using the PKCS#12
+13 −7
Original line number Diff line number Diff line
@@ -124,9 +124,12 @@
     OpenSSL binary ("openssl"). The libraries will be built in the top-level
     directory, and the binary will be in the "apps" directory.

     If "make" fails, please report the problem to <openssl-bugs@openssl.org>
     (note that your message will be forwarded to a public mailing list).
     Include the output of "make report" in your message.
     If "make" fails, look at the output.  There may be reasons for
     the failure that isn't a problem in OpenSSL itself (like missing
     standard headers).  If it is a problem with OpenSSL itself, please
     report the problem to <openssl-bugs@openssl.org> (note that your
     message will be forwarded to a public mailing list).  Include the
     output of "make report" in your message.

     [If you encounter assembler error messages, try the "no-asm"
     configuration option as an immediate fix.]
@@ -138,10 +141,13 @@

       $ make test

    If a test fails, try removing any compiler optimization flags from
    the CFLAGS line in Makefile.ssl and run "make clean; make". Please
    send a bug report to <openssl-bugs@openssl.org>, including the
    output of "make report".
     If a test fails, look at the output.  There may be reasons for
     the failure that isn't a problem in OpenSSL itself (like a missing
     or malfunctioning bc).  If it is a problem with OpenSSL itself,
     try removing any compiler optimization flags from the CFLAGS line
     in Makefile.ssl and run "make clean; make". Please send a bug
     report to <openssl-bugs@openssl.org>, including the output of
     "make report".

  4. If everything tests ok, install OpenSSL with

+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@
 *
 */
#include "apps.h"
#include <string.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/engine.h>
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@
 */

#include <stdio.h>
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/asn1.h>
+1 −3
Original line number Diff line number Diff line
@@ -113,11 +113,9 @@ ASN1_TIME *d2i_ASN1_TIME(ASN1_TIME **a, unsigned char **pp, long length)
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
	{
	struct tm *ts;
#if defined(THREADS) && !defined(WIN32)
#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
	struct tm data;
#endif

#if defined(THREADS) && !defined(WIN32)
	gmtime_r(&t,&data);
	ts=&data; /* should return &data, but doesn't on some systems, so we don't even look at the return value */
#else
Loading