diff -rupN openssl-1.0.0d/apps/apps.c openssl-1.0.0d-engine-srv-cert/apps/apps.c
--- openssl-1.0.0d/apps/apps.c	2010-11-11 17:42:19.000000000 +0300
+++ openssl-1.0.0d-engine-srv-cert/apps/apps.c	2011-03-01 18:19:30.000000000 +0300
@@ -786,8 +786,30 @@ static int load_pkcs12(BIO *err, BIO *in
 X509 *load_cert(BIO *err, const char *file, int format,
 	const char *pass, ENGINE *e, const char *cert_descrip)
 	{
-	X509 *x=NULL;
-	BIO *cert;
+	X509 *x = NULL;
+	BIO *cert = NULL;
+
+	PW_CB_DATA cb_data;
+
+	cb_data.password = pass;
+	cb_data.prompt_info = file;
+
+    if(file == NULL && format != FORMAT_ENGINE){
+    	BIO_printf(err,"no certfile specified\n");
+		goto end;
+    }
+
+#ifndef OPENSSL_NO_ENGINE
+	if (format == FORMAT_ENGINE)
+		{
+		if (!e)
+			BIO_printf(bio_err,"no engine specified\n");
+		else
+			x = ENGINE_load_server_certificate(e, file,
+				ui_method, &cb_data);
+		goto end;
+		}
+#endif
 
 	if ((cert=BIO_new(BIO_s_file())) == NULL)
 		{
diff -rupN openssl-1.0.0d/apps/s_server.c openssl-1.0.0d-engine-srv-cert/apps/s_server.c
--- openssl-1.0.0d/apps/s_server.c	2010-06-15 21:25:02.000000000 +0400
+++ openssl-1.0.0d-engine-srv-cert/apps/s_server.c	2011-03-01 18:19:46.000000000 +0300
@@ -476,7 +476,7 @@ static void sv_usage(void)
 	BIO_printf(bio_err," -www          - Respond to a 'GET /' with a status page\n");
 	BIO_printf(bio_err," -WWW          - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
 	BIO_printf(bio_err," -HTTP         - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
-        BIO_printf(bio_err,"                 with the assumption it contains a complete HTTP response.\n");
+    BIO_printf(bio_err,"                 with the assumption it contains a complete HTTP response.\n");
 #ifndef OPENSSL_NO_ENGINE
 	BIO_printf(bio_err," -engine id    - Initialise and use the specified engine\n");
 #endif
diff -rupN openssl-1.0.0d/crypto/engine/engine.h openssl-1.0.0d-engine-srv-cert/crypto/engine/engine.h
--- openssl-1.0.0d/crypto/engine/engine.h	2011-01-30 04:05:37.000000000 +0300
+++ openssl-1.0.0d-engine-srv-cert/crypto/engine/engine.h	2011-03-01 19:14:33.000000000 +0300
@@ -281,6 +281,8 @@ typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGI
 /* Generic load_key function pointer */
 typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
 	UI_METHOD *ui_method, void *callback_data);
+typedef X509 * (*ENGINE_LOAD_SRV_CERT_PTR)(ENGINE *, const char *,
+	UI_METHOD *ui_method, void *callback_data);
 typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl,
 	STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **pkey,
 	STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data);
@@ -342,6 +344,7 @@ void ENGINE_load_gmp(void);
 #ifndef OPENSSL_NO_GOST
 void ENGINE_load_gost(void);
 #endif
+
 #endif
 void ENGINE_load_cryptodev(void);
 void ENGINE_load_builtin_engines(void);
@@ -478,6 +481,7 @@ int ENGINE_set_finish_function(ENGINE *e
 int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
 int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f);
 int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
+int ENGINE_set_load_server_cert_function(ENGINE *e, ENGINE_LOAD_SRV_CERT_PTR loadsrvcert_f);
 int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
 				ENGINE_SSL_CLIENT_CERT_PTR loadssl_f);
 int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
@@ -517,6 +521,7 @@ ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finis
 ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
 ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
 ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
+ENGINE_LOAD_SRV_CERT_PTR ENGINE_get_load_server_cert_function(const ENGINE *e);
 ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e);
 ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
 ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
@@ -561,6 +566,9 @@ EVP_PKEY *ENGINE_load_private_key(ENGINE
 	UI_METHOD *ui_method, void *callback_data);
 EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
 	UI_METHOD *ui_method, void *callback_data);
+X509 *ENGINE_load_server_certificate(ENGINE *e, const char *cert_id,
+	UI_METHOD *ui_method, void *callback_data);
+
 int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
 	STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey,
 	STACK_OF(X509) **pother,
@@ -768,6 +776,7 @@ void ERR_load_ENGINE_strings(void);
 #define ENGINE_F_ENGINE_LIST_REMOVE			 121
 #define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY		 150
 #define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY			 151
+#define ENGINE_F_ENGINE_LOAD_SERVER_CERTIFICATE	 153
 #define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT		 194
 #define ENGINE_F_ENGINE_NEW				 122
 #define ENGINE_F_ENGINE_REMOVE				 123
@@ -796,12 +805,13 @@ void ERR_load_ENGINE_strings(void);
 #define ENGINE_R_DSA_NOT_IMPLEMENTED			 140
 #define ENGINE_R_DSO_FAILURE				 104
 #define ENGINE_R_DSO_NOT_FOUND				 132
-#define ENGINE_R_ENGINES_SECTION_ERROR			 148
-#define ENGINE_R_ENGINE_CONFIGURATION_ERROR		 102
-#define ENGINE_R_ENGINE_IS_NOT_IN_LIST			 105
-#define ENGINE_R_ENGINE_SECTION_ERROR			 149
-#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY		 128
-#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY		 129
+#define ENGINE_R_ENGINES_SECTION_ERROR			   148
+#define ENGINE_R_ENGINE_CONFIGURATION_ERROR		   102
+#define ENGINE_R_ENGINE_IS_NOT_IN_LIST			   105
+#define ENGINE_R_ENGINE_SECTION_ERROR			   149
+#define ENGINE_R_FAILED_LOADING_SERVER_CERTIFICATE 127
+#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY		   128
+#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY		   129
 #define ENGINE_R_FINISH_FAILED				 106
 #define ENGINE_R_GET_HANDLE_FAILED			 107
 #define ENGINE_R_ID_OR_NAME_MISSING			 108
diff -rupN openssl-1.0.0d/crypto/engine/eng_int.h openssl-1.0.0d-engine-srv-cert/crypto/engine/eng_int.h
--- openssl-1.0.0d/crypto/engine/eng_int.h	2008-06-02 01:10:30.000000000 +0400
+++ openssl-1.0.0d-engine-srv-cert/crypto/engine/eng_int.h	2011-03-01 18:20:11.000000000 +0300
@@ -179,6 +179,7 @@ struct engine_st
 	ENGINE_CTRL_FUNC_PTR ctrl;
 	ENGINE_LOAD_KEY_PTR load_privkey;
 	ENGINE_LOAD_KEY_PTR load_pubkey;
+    ENGINE_LOAD_SRV_CERT_PTR load_srv_cert;
 
 	ENGINE_SSL_CLIENT_CERT_PTR load_ssl_client_cert;
 
diff -rupN openssl-1.0.0d/crypto/engine/eng_pkey.c openssl-1.0.0d-engine-srv-cert/crypto/engine/eng_pkey.c
--- openssl-1.0.0d/crypto/engine/eng_pkey.c	2008-06-02 02:45:08.000000000 +0400
+++ openssl-1.0.0d-engine-srv-cert/crypto/engine/eng_pkey.c	2011-03-01 18:30:03.000000000 +0300
@@ -69,6 +69,12 @@ int ENGINE_set_load_pubkey_function(ENGI
 	return 1;
 	}
 
+int ENGINE_set_load_server_cert_function(ENGINE *e, ENGINE_LOAD_SRV_CERT_PTR loadsrvcert_f)
+	{
+	e->load_srv_cert = loadsrvcert_f;
+	return 1;
+	}
+
 int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
 				ENGINE_SSL_CLIENT_CERT_PTR loadssl_f)
 	{
@@ -86,6 +92,11 @@ ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubk
 	return e->load_pubkey;
 	}
 
+ENGINE_LOAD_SRV_CERT_PTR ENGINE_get_load_server_cert_function(const ENGINE *e)
+	{
+	return e->load_srv_cert;
+	}
+
 ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e)
 	{
 	return e->load_ssl_client_cert;
@@ -165,6 +176,42 @@ EVP_PKEY *ENGINE_load_public_key(ENGINE 
 	return pkey;
 	}
 
+X509 *ENGINE_load_server_certificate(ENGINE *e, const char *cert_id,
+	UI_METHOD *ui_method, void *callback_data)
+	{
+	X509 *s_cert;
+
+	if(e == NULL)
+		{
+		ENGINEerr(ENGINE_F_ENGINE_LOAD_SERVER_CERTIFICATE,
+			ERR_R_PASSED_NULL_PARAMETER);
+		return 0;
+		}
+	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
+	if(e->funct_ref == 0)
+		{
+		CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
+		ENGINEerr(ENGINE_F_ENGINE_LOAD_SERVER_CERTIFICATE,
+			ENGINE_R_NOT_INITIALISED);
+		return 0;
+		}
+	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
+	if (!e->load_srv_cert)
+		{
+		ENGINEerr(ENGINE_F_ENGINE_LOAD_SERVER_CERTIFICATE,
+			ENGINE_R_NO_LOAD_FUNCTION);
+		return 0;
+		}
+	s_cert = e->load_srv_cert(e, cert_id, ui_method, callback_data);
+	if (!s_cert)
+		{
+		ENGINEerr(ENGINE_F_ENGINE_LOAD_SERVER_CERTIFICATE,
+			ENGINE_R_FAILED_LOADING_SERVER_CERTIFICATE);
+		return 0;
+		}
+	return s_cert;
+	}
+
 int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
 	STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey,
 	STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data)
