diff -ur openca-0.9/src/ocspd/src/config.h.in openca-0.9-patched-for-ocspd/src/ocspd/src/config.h.in
--- openca-0.9/src/ocspd/src/config.h.in	Mon Aug 12 16:42:43 2002
+++ openca-0.9-patched-for-ocspd/src/ocspd/src/config.h.in	Fri Oct 28 19:02:43 2005
@@ -15,7 +15,12 @@
 #undef inline
 
 /* Define if you have the ANSI C header files.  */
-#undef STDC_HEADERS
+#include <openssl/crypto.h>
+# if (OPENSSL_VERSION_NUMBER >= 0x00908000L)
+#   define STDC_HEADERS 1
+# else
+#   undef STDC_HEADERS
+# endif
 
 /* Define if your ssl headers are included with #include <openssl/header.h>  */
 #undef HAVE_OPENSSL
diff -ur openca-0.9/src/ocspd/src/db.c openca-0.9-patched-for-ocspd/src/ocspd/src/db.c
--- openca-0.9/src/ocspd/src/db.c	Mon May 17 21:11:24 2004
+++ openca-0.9-patched-for-ocspd/src/ocspd/src/db.c	Wed Nov  2 18:30:42 2005
@@ -412,7 +412,34 @@
 
 	for (i=0; i<DB_NUMBER; i++)
 		row[i]=NULL;
-	row[DB_name]=X509_NAME_oneline(X509_get_subject_name(x509),NULL,0);
+
+        BIO *bio_out; // UTF8 support wants BIO:
+        BUF_MEM *buf;
+
+        // write subject name to bio using recommended OpenSSL template: 
+        bio_out = BIO_new(BIO_s_mem());
+        X509_NAME_print_ex (bio_out, X509_get_subject_name(x509),
+                            0, XN_FLAG_RFC2253&(~ASN1_STRFLGS_ESC_MSB));
+
+        // get subject name from bio using recommended OpenSSL template:
+        int fullsize = 0, newsize = 0;
+        buf = BUF_MEM_new();
+        for (;;) {
+            if ((buf == NULL) || (!BUF_MEM_grow(buf, fullsize+512)))
+                printf("Failed to allocate buffer\n");
+                exit(1);
+            newsize = BIO_read(bio_out, &(buf->data[fullsize]), 512);
+            fullsize += newsize;
+            if (newsize == 0) break;
+            if (newsize < 0) {
+                printf("Error reading from buffer\n");
+                exit(1);
+            }
+        }
+        row[DB_name]=(unsigned char *)buf->data;
+        if (bio_out != NULL) BIO_free(bio_out);
+        if (buf != NULL) BUF_MEM_free(buf);
+
 	bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(x509),NULL);
 	row[DB_serial]=BN_bn2hex(bn);
 	BN_free(bn);
