#include <stdio.h>
#include "cryptlib.h"
-#include "bn.h"
-#include "evp.h"
-#include "asn1.h"
-#include "x509.h"
-#include "objects.h"
-#include "buffer.h"
-#include "pem.h"
+#include <openssl/bn.h>
+#include <openssl/evp.h>
+#include <openssl/asn1.h>
+#include <openssl/x509.h>
+#include <openssl/objects.h>
+#include <openssl/buffer.h>
-X509 *X509_REQ_to_X509(r,days,pkey)
-X509_REQ *r;
-int days;
-EVP_PKEY *pkey;
+X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
{
X509 *ret=NULL;
- int er=1;
- X509_REQ_INFO *ri=NULL;
X509_CINF *xi=NULL;
X509_NAME *xn;
}
/* duplicate the request */
- ri=(X509_REQ_INFO *)ASN1_dup(i2d_X509_REQ_INFO,
- (char *(*)())d2i_X509_REQ_INFO,(char *)r->req_info);
- if (ri == NULL) goto err;
-
xi=ret->cert_info;
- if (sk_num(ri->attributes) != 0)
+ if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0)
{
- if ((xi->version=ASN1_INTEGER_new()) == NULL) goto err;
+ if ((xi->version=M_ASN1_INTEGER_new()) == NULL) goto err;
if (!ASN1_INTEGER_set(xi->version,2)) goto err;
/* xi->extensions=ri->attributes; <- bad, should not ever be done
ri->attributes=NULL; */
if (!X509_sign(ret,pkey,EVP_md5()))
goto err;
- er=0;
-err:
- if (er)
+ if (0)
{
+err:
X509_free(ret);
- X509_REQ_INFO_free(ri);
- return(NULL);
+ ret=NULL;
}
return(ret);
}