diff -r -u3 mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/libssl.module mod_ssl-2.3.5-1.3.6/pkg.sslmod/libssl.module
--- mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/libssl.module	Tue May 25 04:56:00 1999
+++ mod_ssl-2.3.5-1.3.6/pkg.sslmod/libssl.module	Wed Jul 14 10:46:07 1999
@@ -243,6 +243,42 @@
             SSL_CFLAGS="$SSL_CFLAGS -DSSL_USE_SDBM"
         fi
     fi
+    #
+    #   determine DB support library (for SSLCertificateDB)
+    #
+    DB_VERSION=''
+    DB_LIB=''
+#    if ./helpers/TestCompile func db_open; then
+#        DB_VERSION='Berkeley-DB/2.x'
+#    else
+#        if ./helpers/TestCompile lib db db_open; then
+#            DB_VERSION='Berkeley-DB/2.x'
+#            DB_LIB='-ldb'
+#        else
+            if ./helpers/TestCompile func dbopen; then
+                DB_VERSION='Berkeley-DB/1.x'
+            else
+                if ./helpers/TestCompile lib db dbopen; then
+                    DB_VERSION='Berkeley-DB/1.x'
+                    DB_LIB='-ldb'
+                fi
+            fi 
+#        fi
+#    fi
+    if [ ".$DB_VERSION" != . ]; then
+        if [ ".$DB_LIB" != . ]; then
+            LIBS="$LIBS $DB_LIB"
+            echo "$my_prefix SSL interface plugin: $DB_VERSION for crt/key dbfile ($DB_LIB)"
+        else
+            echo "$my_prefix SSL interface plugin: $DB_VERSION for crt/key dbfile (-lc)"
+        fi
+    else
+        echo "Error: Neither Berkeley-DB/1.x nor Berkeley-DB/2.x library found."
+        echo "       Either disable mod_auth_db or provide us with the paths"
+        echo "       to the Berkeley-DB include and library files."
+        echo "       (Hint: INCLUDES, LDFLAGS, LIBS)"
+        exit 1
+    fi
 
     #
     #   determine SSL_BASE
diff -r -u3 mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/mod_ssl.c mod_ssl-2.3.5-1.3.6/pkg.sslmod/mod_ssl.c
--- mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/mod_ssl.c	Tue Jul 13 15:36:54 1999
+++ mod_ssl-2.3.5-1.3.6/pkg.sslmod/mod_ssl.c	Tue Jul 13 22:23:24 1999
@@ -108,9 +108,15 @@
     AP_SRV_CMD(CertificateFile, TAKE1,
                "SSL Server Certificate file "
                "(`/path/to/file' - PEM encoded)")
+    AP_SRV_CMD(CertificateDB, TAKE2,
+               "SSL Server Certificate DB File and Key "
+               "(`/path/to/dbfile key' - PEM encoded)")
     AP_SRV_CMD(CertificateKeyFile, TAKE1,
                "SSL Server Private Key file "
                "(`/path/to/file' - PEM encoded)")
+    AP_SRV_CMD(CertificateKeyDB, TAKE2,
+               "SSL Server Private Key DB File and Key "
+               "(`/path/to/dbfile key' - PEM encoded)")
 #ifdef SSL_EXPERIMENTAL
     AP_ALL_CMD(CACertificatePath, TAKE1,
                "SSL CA Certificate path "
diff -r -u3 mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/mod_ssl.h mod_ssl-2.3.5-1.3.6/pkg.sslmod/mod_ssl.h
--- mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/mod_ssl.h	Tue Jul 13 15:36:54 1999
+++ mod_ssl-2.3.5-1.3.6/pkg.sslmod/mod_ssl.h	Wed Jul 14 01:17:42 1999
@@ -405,6 +405,20 @@
 } ssl_pphrase_t;
 
 /*
+ * Define the SSL source type (for grabbing keys or certificats)
+ */
+typedef enum {
+    SSL_SOURCE_FILE = 0,
+    SSL_SOURCE_DB   = 1
+} ssl_source_type_t;
+
+typedef struct {
+    char              *szDataA;
+    char              *szDataB;
+    ssl_source_type_t  nType;
+} ssl_source_t;
+
+/*
  * Define the Path Checking modes
  */
 #define SSL_PCM_EXISTS     1
@@ -516,8 +530,8 @@
  */
 typedef struct {
     BOOL         bEnabled;
-    char        *szPublicCertFile[SSL_AIDX_MAX];
-    char        *szPrivateKeyFile[SSL_AIDX_MAX];
+    ssl_source_t *pPublicCertSource[SSL_AIDX_MAX];
+    ssl_source_t *pPrivateKeySource[SSL_AIDX_MAX];
     char        *szCACertificatePath;
     char        *szCACertificateFile;
     char        *szLogFile;
@@ -586,7 +600,9 @@
 const char  *ssl_cmd_SSLEngine(cmd_parms *, char *, int flag);
 const char  *ssl_cmd_SSLCipherSuite(cmd_parms *, SSLDirConfigRec *, char *);
 const char  *ssl_cmd_SSLCertificateFile(cmd_parms *, char *, char *);
+const char  *ssl_cmd_SSLCertificateDB(cmd_parms *, char *, char *, char *);
 const char  *ssl_cmd_SSLCertificateKeyFile(cmd_parms *, char *, char *);
+const char  *ssl_cmd_SSLCertificateKeyDB(cmd_parms *, char *, char *, char *);
 const char  *ssl_cmd_SSLCACertificatePath(cmd_parms *, SSLDirConfigRec *, char *);
 const char  *ssl_cmd_SSLCACertificateFile(cmd_parms *, SSLDirConfigRec *, char *);
 const char  *ssl_cmd_SSLCARevocationPath(cmd_parms *, SSLDirConfigRec *, char *);
@@ -661,6 +677,7 @@
 /*  Pass Phrase Support  */
 void         ssl_pphrase_Handle(server_rec *, pool *, BOOL);
 int          ssl_pphrase_Handle_CB(char *, int, int);
+FILE*        ssl_pphrase_Handle_dbfile(server_rec *, pool *, char *, char *);
 
 /*  Diffie-Hellman Parameter Support  */
 DH           *ssl_dh_GetTmpParam(int);
diff -r -u3 mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/ssl_engine_config.c mod_ssl-2.3.5-1.3.6/pkg.sslmod/ssl_engine_config.c
--- mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/ssl_engine_config.c	Tue Jul 13 15:36:54 1999
+++ mod_ssl-2.3.5-1.3.6/pkg.sslmod/ssl_engine_config.c	Tue Jul 13 22:53:04 1999
@@ -204,8 +204,8 @@
     sc->szCARevocationFile     = NULL;
     sc->pRevocationStore       = NULL;
 
-    (void)memset(sc->szPublicCertFile, 0, SSL_AIDX_MAX*sizeof(char *));
-    (void)memset(sc->szPrivateKeyFile, 0, SSL_AIDX_MAX*sizeof(char *));
+    (void)memset(sc->pPublicCertSource, 0, SSL_AIDX_MAX*sizeof(ssl_source_t *));
+    (void)memset(sc->pPrivateKeySource, 0, SSL_AIDX_MAX*sizeof(ssl_source_t *));
     (void)memset(sc->pPublicCert, 0, SSL_AIDX_MAX*sizeof(X509 *));
     (void)memset(sc->pPrivateKey, 0, SSL_AIDX_MAX*sizeof(EVP_PKEY *));
 
@@ -249,8 +249,8 @@
     cfgMerge(pRevocationStore, NULL);
 
     for (i = 0; i < SSL_AIDX_MAX; i++) {
-        cfgMergeString(szPublicCertFile[i]);
-        cfgMergeString(szPrivateKeyFile[i]);
+        cfgMergeString(pPublicCertSource[i]); /* even though not a string, this works */
+        cfgMergeString(pPrivateKeySource[i]); /* even though not a string, this works */
         cfgMerge(pPublicCert[i], NULL);
         cfgMerge(pPrivateKey[i], NULL);
     }
@@ -492,19 +492,51 @@
 {
     SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
     char *cpPath;
+    ssl_source_t *pSource;
     int i;
 
     cpPath = ap_server_root_relative(cmd->pool, arg);
     if (!ssl_util_path_check(SSL_PCM_EXISTS|SSL_PCM_ISREG|SSL_PCM_ISNONZERO, cpPath))
         return ap_pstrcat(cmd->pool, "SSLCertificateFile: file '",
                           cpPath, "' not exists or empty", NULL);
-    for (i = 0; i < SSL_AIDX_MAX && sc->szPublicCertFile[i] != NULL; i++)
+    pSource = (ssl_source_t*)ap_palloc(cmd->pool, sizeof(ssl_source_t));
+    pSource->nType = SSL_SOURCE_FILE;
+    pSource->szDataA = cpPath;
+    pSource->szDataB = NULL;
+    for (i = 0; i < SSL_AIDX_MAX && sc->pPublicCertSource[i] != NULL; i++)
         ;
     if (i == SSL_AIDX_MAX)
         return ap_psprintf(cmd->pool, "SSLCertificateFile: only up to %d "
                           "different certificates per virtual host allowed", 
                           SSL_AIDX_MAX);
-    sc->szPublicCertFile[i] = cpPath;
+    sc->pPublicCertSource[i] = pSource;
+    return NULL;
+}
+
+const char *ssl_cmd_SSLCertificateDB(
+    cmd_parms *cmd, char *struct_ptr, char *arg_dbfile, char *arg_key)
+{
+    SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
+    char *cpPath;
+    char *cpKey;
+    ssl_source_t *pSource;
+    int i;
+
+    cpPath = ap_server_root_relative(cmd->pool, arg_dbfile);
+    if (!ssl_util_path_check(SSL_PCM_EXISTS|SSL_PCM_ISREG|SSL_PCM_ISNONZERO, cpPath))
+        return ap_pstrcat(cmd->pool, "SSLCertificateDB: file '",
+                          cpPath, "' not exists or empty", NULL);
+    pSource = (ssl_source_t*)ap_palloc(cmd->pool, sizeof(ssl_source_t));
+    pSource->nType = SSL_SOURCE_DB;
+    pSource->szDataA = cpPath;
+    pSource->szDataB = ap_pstrdup(cmd->pool, arg_key);
+    for (i = 0; i < SSL_AIDX_MAX && sc->pPublicCertSource[i] != NULL; i++)
+        ;
+    if (i == SSL_AIDX_MAX)
+        return ap_psprintf(cmd->pool, "SSLCertificateDB: only up to %d "
+                          "different certificates per virtual host allowed", 
+                          SSL_AIDX_MAX);
+    sc->pPublicCertSource[i] = pSource;
     return NULL;
 }
 
@@ -513,19 +545,50 @@
 {
     SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
     char *cpPath;
+    ssl_source_t *pSource;
     int i;
 
     cpPath = ap_server_root_relative(cmd->pool, arg);
     if (!ssl_util_path_check(SSL_PCM_EXISTS|SSL_PCM_ISREG|SSL_PCM_ISNONZERO, cpPath))
         return ap_pstrcat(cmd->pool, "SSLCertificateKeyFile: file '",
                           cpPath, "' not exists or empty", NULL);
-    for (i = 0; i < SSL_AIDX_MAX && sc->szPrivateKeyFile[i] != NULL; i++)
+    pSource = (ssl_source_t*)ap_palloc(cmd->pool, sizeof(ssl_source_t));
+    pSource->nType = SSL_SOURCE_FILE;
+    pSource->szDataA = cpPath;
+    pSource->szDataB = NULL;
+    for (i = 0; i < SSL_AIDX_MAX && sc->pPrivateKeySource[i] != NULL; i++)
         ;
     if (i == SSL_AIDX_MAX)
         return ap_psprintf(cmd->pool, "SSLCertificateKeyFile: only up to %d "
                           "different private keys per virtual host allowed", 
                           SSL_AIDX_MAX);
-    sc->szPrivateKeyFile[i] = cpPath;
+    sc->pPrivateKeySource[i] = pSource;
+    return NULL;
+}
+
+const char *ssl_cmd_SSLCertificateKeyDB(
+    cmd_parms *cmd, char *struct_ptr, char *arg_dbfile, char *arg_key)
+{
+    SSLSrvConfigRec *sc = mySrvConfig(cmd->server);
+    char *cpPath;
+    ssl_source_t *pSource;
+    int i;
+
+    cpPath = ap_server_root_relative(cmd->pool, arg_dbfile);
+    if (!ssl_util_path_check(SSL_PCM_EXISTS|SSL_PCM_ISREG|SSL_PCM_ISNONZERO, cpPath))
+        return ap_pstrcat(cmd->pool, "SSLCertificateKeyDB: file '",
+                          cpPath, "' not exists or empty", NULL);
+    pSource = (ssl_source_t*)ap_palloc(cmd->pool, sizeof(ssl_source_t));
+    pSource->nType = SSL_SOURCE_DB;
+    pSource->szDataA = cpPath;
+    pSource->szDataB = ap_pstrdup(cmd->pool, arg_key);
+    for (i = 0; i < SSL_AIDX_MAX && sc->pPrivateKeySource[i] != NULL; i++)
+        ;
+    if (i == SSL_AIDX_MAX)
+        return ap_psprintf(cmd->pool, "SSLCertificateKeyDB: only up to %d "
+                          "different private keys per virtual host allowed", 
+                          SSL_AIDX_MAX);
+    sc->pPrivateKeySource[i] = pSource;
     return NULL;
 }
 
diff -r -u3 mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/ssl_engine_init.c mod_ssl-2.3.5-1.3.6/pkg.sslmod/ssl_engine_init.c
--- mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/ssl_engine_init.c	Tue Jul 13 15:36:54 1999
+++ mod_ssl-2.3.5-1.3.6/pkg.sslmod/ssl_engine_init.c	Tue Jul 13 16:28:11 1999
@@ -394,7 +394,7 @@
      * Now check for important parameters and the
      * possibility that the user forgot to set them.
      */
-    if (sc->szPublicCertFile[0] == NULL) {
+    if (sc->pPublicCertSource[0] == NULL) {
         ssl_log(s, SSL_LOG_ERROR,
                 "Init: (%s) No SSL Certificate set [hint: SSLCertificateFile]",
                 cpVHostID);
diff -r -u3 mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/ssl_engine_pphrase.c mod_ssl-2.3.5-1.3.6/pkg.sslmod/ssl_engine_pphrase.c
--- mod_ssl-2.3.5-1.3.6_orig/pkg.sslmod/ssl_engine_pphrase.c	Tue Jul 13 15:36:54 1999
+++ mod_ssl-2.3.5-1.3.6/pkg.sslmod/ssl_engine_pphrase.c	Fri Jul 16 14:27:10 1999
@@ -65,6 +65,13 @@
                                            -- Clifford Stoll     */
 #include "mod_ssl.h"
 
+/* #include <db.h> */
+#include "/usr/include/db1/db.h"
+
+#if defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 2)
+#define DB2
+#endif
+
 
 /*  _________________________________________________________________
 **
@@ -102,6 +109,9 @@
     ssl_algo_t algoCert, algoKey, at;
     char *an;
     char *cp;
+    int bNeedsRewind;
+    int bCloseFile;
+    char* szSourceName;
 
     /*
      * Do nothing on graceful restarts if we have SSL_PTYPE_BUILTIN anywhere
@@ -158,7 +168,7 @@
          * Read in server certificate(s): This is the easy part
          * because this file isn't encrypted in any way.
          */
-        if (sc->szPublicCertFile[0] == NULL) {
+        if (sc->pPublicCertSource[0] == NULL) {
             ssl_log(pServ, SSL_LOG_ERROR,
                     "Init: Server %s should be SSL-aware but has no certificate configured "
                     "[Hint: SSLCertifcateFile]", cpVHostID);
@@ -166,20 +176,43 @@
         }
         algoCert = SSL_ALGO_UNKNOWN;
         algoKey  = SSL_ALGO_UNKNOWN;
-        for (i = 0, j = 0; i < SSL_AIDX_MAX && sc->szPublicCertFile[i] != NULL; i++) {
+        for (i = 0, j = 0; i < SSL_AIDX_MAX && sc->pPublicCertSource[i] != NULL; i++) {
 
-            ap_cpystrn(szPath, sc->szPublicCertFile[i], sizeof(szPath));
-            if ((fp = ap_pfopen(p, szPath, "r")) == NULL) {
-                ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO,
-                        "Init: Can't open server certificate file %s", szPath);
-                ssl_die();
+            /*
+             * Read this certificate depending on the
+             * ssl_source_type_t configuration
+             */
+            if ( sc->pPublicCertSource[i]->nType == SSL_SOURCE_FILE )
+            {
+                ap_cpystrn(szPath, sc->pPublicCertSource[i]->szDataA, sizeof(szPath));
+                if ((fp = ap_pfopen(p, szPath, "r")) == NULL) {
+                    ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO,
+                            "Init: Can't open server certificate file %s", szPath);
+                    ssl_die();
+                }
+                if ((pX509Cert = SSL_read_X509(fp, NULL, NULL)) == NULL) {
+                    ssl_log(s, SSL_LOG_ERROR|SSL_ADD_SSLERR,
+                            "Init: Unable to read server certificate from file %s", szPath);
+                    ssl_die();
+                }
+                ap_pfclose(p, fp);
             }
-            if ((pX509Cert = SSL_read_X509(fp, NULL, NULL)) == NULL) {
-                ssl_log(s, SSL_LOG_ERROR|SSL_ADD_SSLERR,
-                        "Init: Unable to read server certificate from file %s", szPath);
+            else if ( sc->pPublicCertSource[i]->nType == SSL_SOURCE_DB )
+            {
+                fp = ssl_pphrase_Handle_dbfile(s, p, sc->pPublicCertSource[i]->szDataA, 
+                                               sc->pPublicCertSource[i]->szDataB);
+                if ((pX509Cert = SSL_read_X509(fp, NULL, NULL)) == NULL) {
+                    ssl_log(s, SSL_LOG_ERROR|SSL_ADD_SSLERR,
+                            "Init: Unable to read server certificate from dbfile %s key %s",
+                            sc->pPublicCertSource[i]->szDataA, sc->pPublicCertSource[i]->szDataB);
+                    ssl_die();
+                }
+            }
+            else {
+                ssl_log(s, SSL_LOG_ERROR,
+                        "Init: Invalid ssl_source_type_t in cert %d of %s vhost", i, cpVHostID);
                 ssl_die();
             }
-            ap_pfclose(p, fp);
 
             /*
              * check algorithm type of certificate and make
@@ -229,8 +262,37 @@
              * phrase for all). When this is the case we can minimize the dialogs
              * by trying to re-use already known/entered pass phrases.
              */
-            if (sc->szPrivateKeyFile[j] != NULL)
-                ap_cpystrn(szPath, sc->szPrivateKeyFile[j++], sizeof(szPath));
+            if (sc->pPrivateKeySource[j] == NULL)
+                continue;
+
+            if (sc->pPrivateKeySource[j]->nType == SSL_SOURCE_FILE)
+            {
+                ap_cpystrn(szPath, sc->pPrivateKeySource[j]->szDataA, sizeof(szPath));
+                if ((fp = ap_pfopen(p, szPath, "r")) == NULL) {
+                    ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO,
+                            "Init: Can't open server private key file %s", szPath);
+                    ssl_die();
+                }
+                szSourceName = ap_psprintf(p, "file %s", szPath);
+                bNeedsRewind = 0;
+                bCloseFile = 1;
+            }
+            else if (sc->pPrivateKeySource[j]->nType == SSL_SOURCE_DB)
+            {
+                fp = ssl_pphrase_Handle_dbfile(s, p, sc->pPrivateKeySource[j]->szDataA,
+                                               sc->pPrivateKeySource[j]->szDataB);
+                szSourceName = ap_psprintf(p, "dbfile %s key %s",
+                                           sc->pPrivateKeySource[j]->szDataA,
+                                           sc->pPrivateKeySource[j]->szDataB);
+                bNeedsRewind = 0;
+                bCloseFile = 0;
+            }
+            else {
+                ssl_log(s, SSL_LOG_ERROR,
+                        "Init: Invalid ssl_source_type_t in key %d of %s vhost", j, cpVHostID);
+                ssl_die();
+            }
+            j++;
 
             /*
              * Try to read the private key file with the help of
@@ -260,15 +322,12 @@
                  * the callback function which serves the pass
                  * phrases to OpenSSL
                  */
-                if ((fp = ap_pfopen(p, szPath, "r")) == NULL) {
-                    ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO,
-                            "Init: Can't open server private key file %s", szPath);
-                    ssl_die();
-                }
+                if (bNeedsRewind)
+                    (void)fseek(fp, 0L, SEEK_SET); /* perhaps we should check the return value??? */
                 cpPassPhraseCur = NULL;
                 bReadable = ((pPrivateKey = SSL_read_PrivateKey(fp, NULL,
                              ssl_pphrase_Handle_CB)) != NULL ? TRUE : FALSE);
-                ap_pfclose(p, fp);
+                bNeedsRewind = 1;
 
                 /*
                  * when the private key file now was readable,
@@ -333,6 +392,12 @@
             }
 
             /*
+             * close the file if needed
+             */
+            if (bCloseFile)
+                ap_pfclose(p, fp);
+
+            /*
              * check algorithm type of private key and make
              * sure only one private key per type is used.
              */
@@ -392,6 +457,11 @@
     }
 
     /*
+     * Close and dbfile that might be open
+     */
+    ssl_pphrase_Handle_dbfile(s, p, NULL, NULL);
+
+    /*
      * Let the user know when we're successful.
      */
     if (nPassPhraseDialog > 0) {
@@ -556,5 +626,116 @@
      * And return it's length to OpenSSL...
      */
     return (len);
+}
+
+FILE* ssl_pphrase_Handle_dbfile(server_rec *s, pool *p, char *dbfile, char *key)
+{
+    static char *current_dbfile = NULL;
+    static char *current_key = NULL;
+    static DB *db;
+    static FILE *fp = NULL;
+    DBT dbkey;
+    DBT dbval;
+    char *tempfilename;
+
+    /*
+     * Close the database and temporary file and exit 
+     * when called to do a cleanup
+     */
+    if (dbfile == NULL) {
+        current_key = NULL;
+        if (current_dbfile != NULL) {
+#ifdef DB2
+            (db->close) (db, 0);
+#else
+            (db->close) (db);
+#endif
+            current_dbfile = NULL;
+        }
+        if (fp != NULL) {
+            ap_pfclose(p, fp);
+            fp == NULL;
+        }
+        return NULL;
+    }
+
+    /*
+     * Open a new database, if needed
+     */
+    if (current_dbfile == NULL || strNE(dbfile, current_dbfile)) {
+        if (current_dbfile != NULL) {
+#ifdef DB2
+            (db->close) (db, 0);
+#else
+            (db->close) (db);
+#endif
+        }
+#ifdef DB2
+        if (db_open(dbfile, DB_HASH, DB_RDONLY, 0664, NULL, NULL, &db) != 0) {
+#else
+        if (!(db = dbopen(dbfile, O_RDONLY, 0664, DB_HASH, NULL))) {
+#endif
+           ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO,
+                   "Init: Can't open cert/key DBM %s", dbfile);
+           ssl_die();
+        }
+        current_dbfile = dbfile;
+    }
+
+    /*
+     * Open a new unlinked temporary file if we don't have one already
+     */
+    if (fp == NULL) {
+        if ((tempfilename = tempnam(NULL, "modssl")) == NULL) {
+            ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO, "Init: Can't get temporary file name");
+            ssl_die();
+        }
+        if ((fp = ap_pfopen(p, tempfilename, "w+")) == NULL) {
+            ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO, 
+                    "Init: Can't open temporary file %s", tempfilename);
+            ssl_die();
+        }
+        if (unlink(tempfilename) != 0) {
+            ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO, 
+                    "Init: Can't unlink temporary file %s", tempfilename);
+            ssl_die();
+        }
+    }
+
+    /*
+     * Lookup the key and load the data into the temporary file, if not already there
+     */
+    if (current_key == NULL || strNE(key, current_key)) {
+
+        /* read the key */
+        dbkey.data = key;
+        dbkey.size = strlen(key);
+#ifdef DB2
+        if ((db->get) (db, NULL, &dbkey, &dbval, 0)) {
+#else
+        if ((db->get) (db, &dbkey, &dbval, 0)) {
+#endif
+            ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO,
+                    "Init: key %s not found in DB_File %s", key, dbfile);
+            ssl_die();
+	    }
+
+        /* load the temporary file */
+        fflush(fp);
+        rewind(fp);
+        ftruncate(fileno(fp), 0);
+        if (fwrite((void*)dbval.data, (size_t)dbval.size, 1, fp) != 1) {
+            ssl_log(s, SSL_LOG_ERROR|SSL_ADD_ERRNO, "Init: Can't write to temporary file");
+            ssl_die();
+        }
+        rewind(fp);
+
+        current_key = key;
+    }
+    else {
+        rewind(fp);
+    }
+
+    return fp;
 }
 
