Initial support for enveloped data decrypt. Extent runex.pl to cover these
[openssl.git] / apps / ocsp.c
index 856bead88a6e1cb10212bd58e88d763d68d11400..c436c8b6f390ed174a53e5dd6c5ca6e1e383dfc1 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
+#include "apps.h" /* needs to be included before the openssl headers! */
 #include <openssl/e_os2.h>
-#include <openssl/bio.h>
-#include <openssl/ocsp.h>
-#include <openssl/txt_db.h>
 #include <openssl/ssl.h>
 #include <openssl/evp.h>
-#include "apps.h"
 
+#if defined(NETWARE_CLIB)
+#  ifdef NETWARE_BSDSOCK
+#    include <sys/socket.h>
+#    include <sys/bsdskt.h>
+#  else
+#    include <novsock2.h>
+#  endif
+#elif defined(NETWARE_LIBC)
+#  ifdef NETWARE_BSDSOCK
+#    include <sys/select.h>
+#  else
+#    include <novsock2.h>
+#  endif
+#endif
+  
 /* Maximum leeway in validity period: default 5 minutes */
 #define MAX_VALIDITY_PERIOD    (5 * 60)
 
@@ -1029,7 +1042,6 @@ static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db
                goto end;
                }
 
-       ca_id = OCSP_cert_to_id(EVP_sha1(), NULL, ca);
 
        bs = OCSP_BASICRESP_new();
        thisupd = X509_gmtime_adj(NULL, 0);
@@ -1042,8 +1054,23 @@ static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, CA_DB *db
                OCSP_ONEREQ *one;
                ASN1_INTEGER *serial;
                char **inf;
+               ASN1_OBJECT *cert_id_md_oid;
+               const EVP_MD *cert_id_md;
                one = OCSP_request_onereq_get0(req, i);
                cid = OCSP_onereq_get0_id(one);
+
+               OCSP_id_get0_info(NULL,&cert_id_md_oid, NULL,NULL, cid);
+
+               cert_id_md = EVP_get_digestbyobj(cert_id_md_oid);       
+               if (! cert_id_md) 
+                       {
+                       *resp = OCSP_response_create(OCSP_RESPONSE_STATUS_INTERNALERROR,
+                               NULL);
+                               goto end;
+                       }       
+               if (ca_id) OCSP_CERTID_free(ca_id);
+               ca_id = OCSP_cert_to_id(cert_id_md, NULL, ca);
+
                /* Is this request about our CA? */
                if (OCSP_id_issuer_cmp(ca_id, cid))
                        {