diff -uprN proftpd_org/contrib/mod_proxy/include/proxy/tls.h proftpd/contrib/mod_proxy/include/proxy/tls.h
--- proftpd_org/contrib/mod_proxy/include/proxy/tls.h	2025-11-12 11:44:57.376270709 +0900
+++ proftpd/contrib/mod_proxy/include/proxy/tls.h	2025-11-12 11:17:39.072932762 +0900
@@ -27,7 +27,7 @@
 
 #include "mod_proxy.h"
 #include "proxy/session.h"
-
+#include <curl/curl.h>
 #ifdef PR_USE_OPENSSL
 # include <openssl/bio.h>
 # include <openssl/err.h>
@@ -126,4 +126,29 @@ struct proxy_tls_datastore {
   void *dsh;
 };
 
+/* for CRL Update */
+int setOption(const char* url);
+int setOptWriteCallback();
+size_t cbWriteFunction(char* buff, size_t size, size_t nmemb, void* param);
+size_t writeFunction(char* buff, size_t size, size_t nmemb);
+int doPerform();
+int prePerform();
+int perform();
+int postPerform();
+int getResponse();
+
+#define CURL_URI_LENGTH_MAX 512
+#define CURL_PATH_LEN_MAX 255
+#define CURL_URI_LENGTH_MIN 5
+#define GET_CRL_TIMEOUT_SEC 30
+#define MAX_FILE_SIZE 10*1024*1024
+
+struct _CrlUriInfo
+{
+    int  is_uri_valid;
+    char crl_uri[CURL_URI_LENGTH_MAX + 1];
+    char crl_path[CURL_PATH_LEN_MAX + 1];
+};
+typedef struct _CrlUriInfo CrlUriInfo;
+
 #endif /* MOD_PROXY_TLS_H */
diff -uprN proftpd_org/contrib/mod_proxy/lib/proxy/conn.c proftpd/contrib/mod_proxy/lib/proxy/conn.c
--- proftpd_org/contrib/mod_proxy/lib/proxy/conn.c	2025-11-12 11:44:57.376270709 +0900
+++ proftpd/contrib/mod_proxy/lib/proxy/conn.c	2025-11-12 11:17:39.073932749 +0900
@@ -28,6 +28,7 @@
 # include <sys/uio.h>
 #endif /* HAVE_SYS_UIO_H */
 
+#include <ifaddrs.h>
 #include "proxy/conn.h"
 #include "proxy/dns.h"
 #include "proxy/netio.h"
@@ -113,6 +114,53 @@ static int supported_protocol(const char
   return -1;
 }
 
+void get_ipv4_addr(pool *p, const char* target_if, char* ipstr, int ipstr_size) {
+  struct ifaddrs *if_list;
+  struct ifaddrs *ifa;
+
+  memset(ipstr, 0, ipstr_size);
+  int num = getifaddrs(&if_list);
+  if (num != 0) {
+    return;
+  }
+  for(ifa = if_list; ifa != NULL; ifa=ifa->ifa_next) {
+    memset(ipstr, 0, ipstr_size);
+    if (!strncmp(target_if, ifa->ifa_name, strlen(ifa->ifa_name))) {
+      if (ifa->ifa_addr->sa_family == AF_INET) {
+        inet_ntop(AF_INET, &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr, ipstr, ipstr_size);
+        if (strncmp(ipstr, "127.0.0.1", 9)) {
+            freeifaddrs(if_list);
+            return;
+        }
+      }
+    }
+  }
+  freeifaddrs(if_list);
+}
+char* get_ipv6_addr(pool *p, const char* target_if, char* ipstr, int ipstr_size) {
+  struct ifaddrs *if_list;
+  struct ifaddrs *ifa;
+
+  memset(ipstr, 0, ipstr_size);
+  int num = getifaddrs(&if_list);
+  if (num != 0) {
+    return;
+  }
+  for(ifa = if_list; ifa != NULL; ifa=ifa->ifa_next) {
+    memset(ipstr, 0, ipstr_size);
+    if (!strncmp(target_if, ifa->ifa_name, strlen(ifa->ifa_name))) {
+      if (ifa->ifa_addr->sa_family == AF_INET6) {
+        inet_ntop(AF_INET6, &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr, ipstr, ipstr_size);
+        if (strncmp(ipstr, "[fe00", 5)) {
+            freeifaddrs(if_list);
+            return;
+        }
+      }
+    }
+  }
+  freeifaddrs(if_list);
+}
+
 int proxy_conn_connect_timeout_cb(CALLBACK_FRAME) {
   const struct proxy_session *proxy_sess;
   const pr_netaddr_t *server_addr;
@@ -349,7 +397,8 @@ const struct proxy_conn *proxy_conn_crea
      */
     if (strcmp(proto, "ftps") == 0 &&
         remote_port == PROXY_TLS_IMPLICIT_FTPS_PORT) {
-      use_tls = PROXY_TLS_ENGINE_IMPLICIT;
+      // use_tls = PROXY_TLS_ENGINE_IMPLICIT;
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d]", __LINE__);
     }
 
   } else if (strcmp(proto, "sftp") == 0 ||
@@ -749,23 +798,22 @@ conn_t *proxy_conn_get_server_conn(pool
     }
   }
 
-  bind_addr = proxy_sess->src_addr;
-
   /* We need to set the default inet family to use for the local address of
    * our socket.  We do NOT want to just use the family of the local address of
    * our control connection, since we could be listening on an IPv6 address
    * and want to connect to a backend IPv4 address, or vice versa; see
    * Issue #272.
    */
-  if (bind_addr == NULL) {
-    int remote_family;
 
-    remote_family = pr_netaddr_get_family(remote_addr);
-
-    pr_trace_msg(trace_channel, 9, "using %s family for socket local address",
-      remote_family == AF_INET ? "IPv4" : "IPv6");
-    default_inet_family = pr_inet_set_default_family(p, remote_family);
+  char ipstr[128];
+  if (pr_netaddr_get_family(remote_addr) == AF_INET) {
+    get_ipv4_addr(p, "eth0", ipstr, 128);
+    bind_addr = pr_netaddr_get_addr(p, ipstr, NULL);
+  } else {
+    get_ipv6_addr(p, "eth0", ipstr, 128);
+    bind_addr = pr_netaddr_get_addr(p, ipstr, NULL);
   }
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d][%s]bind_addr[%s]", __LINE__, __func__, pr_netaddr_get_ipstr(bind_addr));
 
   /* Note: IF mod_proxy is running on localhost, and the connection to be
    * made is to a public IP address, then this connect(2) attempt would most
diff -uprN proftpd_org/contrib/mod_proxy/lib/proxy/forward.c proftpd/contrib/mod_proxy/lib/proxy/forward.c
--- proftpd_org/contrib/mod_proxy/lib/proxy/forward.c	2025-11-12 11:44:57.153273857 +0900
+++ proftpd/contrib/mod_proxy/lib/proxy/forward.c	2025-11-12 11:17:39.073932749 +0900
@@ -210,10 +210,11 @@ static int forward_connect(pool *p, stru
 
   /* If the destination port is 990, assume implicit FTPS. */
   if (ntohs(pr_netaddr_get_port(dst_addr)) == PROXY_TLS_IMPLICIT_FTPS_PORT) {
-    pr_trace_msg(trace_channel, 9, "%s#%u requesting, using implicit FTPS",
-      pr_netaddr_get_ipstr(dst_addr),
-      (unsigned int) ntohs(pr_netaddr_get_port(dst_addr)));
-    proxy_tls_set_tls(PROXY_TLS_ENGINE_IMPLICIT);
+   // pr_trace_msg(trace_channel, 9, "%s#%u requesting, using implicit FTPS",
+   //   pr_netaddr_get_ipstr(dst_addr),
+   //   (unsigned int) ntohs(pr_netaddr_get_port(dst_addr)));
+   // proxy_tls_set_tls(PROXY_TLS_ENGINE_IMPLICIT);
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d]", __LINE__);
   }
 
   server_conn = proxy_conn_get_server_conn(p, proxy_sess, dst_addr);
@@ -611,21 +612,31 @@ static int forward_handle_user_passthru(
        */
       resp = pcalloc(cmd->tmp_pool, sizeof(pr_response_t));
       resp->num = R_530;
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[%d] xerrno[%d]", __LINE__, xerrno);
+      if (xerrno == EPERM) {
+         resp->msg = pstrcat(cmd->tmp_pool, "Proxy server cert. error", "", NULL);
+         pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"%s [%d]", __func__, __LINE__);
+      } else {
+         resp->msg = pstrcat(cmd->tmp_pool, "Proxy server connection error", "", NULL);
+         pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"%s [%d]", __func__, __LINE__);
+      }
 
       if (banner != NULL) {
         resp->msg = banner->msg;
         resp_nlines = banner_nlines;
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[%d] xerrno[%d]", __LINE__, xerrno);
 
       } else {
-        resp->msg = pstrcat(cmd->tmp_pool, "Unable to connect to ",
-          proxy_conn_get_hostport(proxy_sess->dst_pconn), ": ",
-          strerror(xerrno), NULL);
+       // resp->msg = pstrcat(cmd->tmp_pool, "Unable to connect to ",
+       //   proxy_conn_get_host(proxy_sess->dst_pconn), ": ",
+       //   strerror(xerrno), NULL);
         resp_nlines = 1;
       }
 
       res = proxy_ftp_ctrl_send_resp(cmd->tmp_pool,
         proxy_sess->frontend_ctrl_conn, resp, resp_nlines);
       if (res < 0) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[%d] xerrno[%d]", __LINE__, xerrno);
         xerrno = errno;
 
         pr_response_block(TRUE);
@@ -633,6 +644,7 @@ static int forward_handle_user_passthru(
         return -1;
       }
 
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[%d] xerrno[%d]", __LINE__, xerrno);
       errno = EINVAL;
       return 1;
     }
diff -uprN proftpd_org/contrib/mod_proxy/lib/proxy/ftp/xfer.c proftpd/contrib/mod_proxy/lib/proxy/ftp/xfer.c
--- proftpd_org/contrib/mod_proxy/lib/proxy/ftp/xfer.c	2025-11-12 11:44:57.154273843 +0900
+++ proftpd/contrib/mod_proxy/lib/proxy/ftp/xfer.c	2025-11-12 11:17:39.073932749 +0900
@@ -132,12 +132,21 @@ int proxy_ftp_xfer_prepare_active(int po
 
       break;
   }
-
+/*
   bind_addr = proxy_sess->src_addr;
   if (bind_addr == NULL) {
     bind_addr = session.c->local_addr;
   }
-
+*/
+  char ipstr[128];
+  if (!ipv6_backend) {
+    get_ipv4_addr(cmd->pool, "eth0", ipstr, 128);
+    bind_addr = pr_netaddr_get_addr(cmd->pool, ipstr, NULL);
+  } else {
+    get_ipv6_addr(cmd->pool, "eth0", ipstr, 128);
+    bind_addr = pr_netaddr_get_addr(cmd->pool, ipstr, NULL);
+  }
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d]   %s",__LINE__,pr_netaddr_get_ipstr(bind_addr));
   if (pr_netaddr_is_loopback(bind_addr) == TRUE &&
       pr_netaddr_is_loopback(proxy_sess->backend_ctrl_conn->remote_addr) != TRUE) {
     const char *local_name;
diff -uprN proftpd_org/contrib/mod_proxy/lib/proxy/tls.c proftpd/contrib/mod_proxy/lib/proxy/tls.c
--- proftpd_org/contrib/mod_proxy/lib/proxy/tls.c	2025-11-12 11:44:57.381270639 +0900
+++ proftpd/contrib/mod_proxy/lib/proxy/tls.c	2025-11-12 11:37:40.605992732 +0900
@@ -22,6 +22,8 @@
  * source distribution.
  */
 
+#include <openssl/x509_vfy.h>
+#include <openssl/x509v3.h>
 #include "mod_proxy.h"
 
 #include "proxy/conn.h"
@@ -36,6 +38,8 @@
 # define HAVE_LIBRESSL  1
 #endif
 
+#define WRITE_LOG(fmt, ...) (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, fmt, ##__VA_ARGS__)
+
 static const char *trace_channel = "proxy.tls";
 
 #if defined(PR_USE_OPENSSL)
@@ -77,6 +81,7 @@ static const char *timing_channel = "tim
 #define PROXY_TLS_DATA_ADAPTIVE_WRITE_MAX_BUFFER_SIZE	(16 * 1024)
 #define PROXY_TLS_DATA_ADAPTIVE_WRITE_BOOST_THRESHOLD	(1024 * 1024)
 #define PROXY_TLS_DATA_ADAPTIVE_WRITE_BOOST_INTERVAL_MS	1000
+#define STR_CRL_URI_LENGTH_MAX 512
 
 #if defined(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)
 static int tls_ssl_opts = (SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_SINGLE_DH_USE)^SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
@@ -123,6 +128,15 @@ static int netio_install_data(void);
 #define PROXY_TLS_IDX_TICKET_KEY		2
 #define PROXY_TLS_IDX_HAD_TICKET		3
 
+static CURL*       easy_handle;
+static FILE*       file_handle;
+static size_t      write_size_ = 0;
+#define CRL_TMP_CNV  "/tmp/ftp_cnv.crl"
+#define CRL_PATH   "/tmp/ftp_ctl.crl"
+#define TMP_INTER_CERT_FILE "/tmp/ftp_inter.crt"
+#define MAX_INTERMEDIATE_CERT_NUM 999 
+#define TMP_BUF_SIZE 1024
+
 #if !defined(OPENSSL_NO_TLSEXT)
 static void tls_tlsext_cb(SSL *, int, int, unsigned char *, int, void *);
 #endif /* !OPENSSL_NO_TLSEXT */
@@ -132,6 +146,14 @@ static int handshake_timeout_cb(CALLBACK
   return 0;
 }
 
+static int skStrCmpMethod(const char *const *a, const char *const *b)
+{
+    size_t al = strlen(*a);
+    size_t bl = strlen(*b);
+    size_t nl = al > bl ? bl+1 : al+1;
+    return strncmp(*a, *b, nl);
+}
+
 const char *proxy_tls_get_errors(void) {
   unsigned int count = 0;
   unsigned long error_code;
@@ -806,6 +828,7 @@ static int cert_match_dns_san(pool *p, X
   if (sans != NULL) {
     register int i;
     int nsans = sk_GENERAL_NAME_num(sans);
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] SAN nsans[%d]", __LINE__, nsans);
 
     for (i = 0; i < nsans; i++) {
       GENERAL_NAME *alt_name = sk_GENERAL_NAME_value(sans, i);
@@ -837,6 +860,7 @@ static int cert_match_dns_san(pool *p, X
           return 0;
         }
 
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] SAN dns_name[%s] dns_san[%s]", __LINE__,dns_name,dns_san);
         if (strncasecmp(dns_name, dns_san, dns_sanlen + 1) == 0) {
           pr_trace_msg(trace_channel, 8,
             "found cert dNSName SAN matching '%s'", dns_name);
@@ -852,6 +876,15 @@ static int cert_match_dns_san(pool *p, X
           pr_trace_msg(trace_channel, 9,
             "cert dNSName SAN '%s' did not match '%s'", dns_san, dns_name);
         }
+       } else if (alt_name->type == GEN_IPADD) {
+        int32_t ipVerifyResult = X509_check_ip_asc(cert,(const char *)dns_name,0);
+        if (1 == ipVerifyResult) {
+          matched = TRUE;
+        }
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] SAN dns_name[%d] ret[%d]",
+                                                              __LINE__, (const char *)dns_name, ipVerifyResult);
+      } else {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] AltName type unknown.", __LINE__);
       }
 
       GENERAL_NAME_free(alt_name);
@@ -1077,6 +1110,8 @@ static int check_server_cert(SSL *ssl, c
       conn->remote_name, X509_verify_cert_error_string(verify_result));
     return -1;
   }
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] remote_addr[%s] host_name[%s]",
+                          __LINE__, pr_netaddr_get_ipstr(conn->remote_addr), host_name);
 
   cert = SSL_get_peer_certificate(ssl);
   if (cert == NULL) {
@@ -1100,20 +1135,27 @@ static int check_server_cert(SSL *ssl, c
    * X509_match_host() and X509_match_ip()/X509_match_ip_asc().
    */
 
+  /* No Check Resolved IP Address
   ok = cert_match_ip_san(conn->pool, cert,
     pr_netaddr_get_ipstr(conn->remote_addr));
   if (ok == 0) {
     ok = cert_match_cn(conn->pool, cert,
       pr_netaddr_get_ipstr(conn->remote_addr), FALSE);
   }
+  */
 
+  ok = cert_match_dns_san(conn->pool, cert, host_name, TRUE);
+  /* No Check CommonName
   if (ok == 0) {
-    ok = cert_match_dns_san(conn->pool, cert, host_name, TRUE);
-    if (ok == 0) {
-      ok = cert_match_cn(conn->pool, cert, host_name, TRUE);
-    }
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+    ok = cert_match_cn(conn->pool, cert, host_name, TRUE);
   }
+  */
 
+  if (ok == 0) {
+    ok = -1;
+  }
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[LINE]%d ok[%d]", __LINE__, ok);
   X509_free(cert);
   return ok;
 }
@@ -1133,9 +1175,779 @@ static void stash_stream_ssl(pr_netio_st
   }
 }
 
+
+int setOption(const char* url)
+{
+  if (!easy_handle) {
+    return 0;
+  }
+  CURLcode curl_err = curl_easy_setopt(easy_handle, CURLOPT_WRITEDATA, 0);
+  if (curl_err == CURLE_OK) {
+    curl_err = curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, cbWriteFunction);
+  }
+  if (curl_err == CURLE_OK) {
+    curl_err = curl_easy_setopt(easy_handle, CURLOPT_URL, url);
+  }
+  if (curl_err == CURLE_OK) {
+    curl_err = curl_easy_setopt(easy_handle, CURLOPT_TIMEOUT, GET_CRL_TIMEOUT_SEC);
+  }
+
+  if (curl_err == CURLE_OK) {
+    return 1;
+  } else {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+    "[tls.info] curl setOption result[%d] ", curl_err);
+    return 0;
+  }
+}
+
+size_t cbWriteFunction(char* buff, size_t size, size_t nmemb, void* param)
+{
+    if (!buff) {
+        return 0;
+    }
+    if (!param) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+      "[tls.info] curl cbWriteFunction param size[%d]  nmemb[%d]", size, nmemb);
+      // no return;
+    }
+    return writeFunction(buff, size, nmemb);
+}
+
+size_t writeFunction(char* buff, size_t size, size_t nmemb)
+{
+    size_t buffer_size = (size * nmemb);
+    if ((write_size_ + buffer_size) > MAX_FILE_SIZE) {
+      return 0;
+    }
+
+    size_t write_size = fwrite(buff, 1, buffer_size, file_handle);
+
+    write_size_ += write_size;
+    return write_size;
+}
+
+int doPerform(const char* dest_file_name)
+{
+  if (!easy_handle) {
+    return 0;
+  }
+  int ret = prePerform(dest_file_name);
+  if (ret != 1) {
+    return ret;
+  }
+  ret = perform();
+  if (ret != 1) {
+    return ret;
+  }
+  postPerform();
+
+  ret = getResponse();
+  if (ret != 1) {
+    return ret;
+  }
+  return 1;
+}
+
+int prePerform(const char* dest_file_name)
+{
+  file_handle = fopen(dest_file_name, "w");
+  if (!file_handle) {
+    struct stat buffer;
+    int exist = stat(dest_file_name, &buffer);
+    if(exist != 0) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      return 2;
+    } else {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      return 0;
+    }
+  }
+
+  return 1;
+}
+
+int perform()
+{
+  CURLM* multi_handle = curl_multi_init();
+  CURLMcode curl_multi_err = curl_multi_add_handle(multi_handle, easy_handle);
+
+  int32_t numfds = 0;
+  int32_t repeats = 0;
+  int32_t still_running = 0;
+  do {
+    curl_multi_err = curl_multi_perform(multi_handle, &still_running);
+    if (curl_multi_err != CURLM_OK) {
+        break;
+    }
+    curl_multi_err = curl_multi_wait(multi_handle, NULL, 0, 500, &numfds);
+    if (curl_multi_err != CURLM_OK) {
+        break;
+    }
+    if (!numfds) {
+        repeats++;
+    }
+    else{
+        repeats = 0;
+    }
+  } while (still_running);
+
+  int32_t msgs_left = 0;
+  CURLMsg* msg = curl_multi_info_read(multi_handle, &msgs_left);
+  curl_multi_remove_handle(multi_handle, easy_handle);
+
+  CURLcode res = CURLE_COULDNT_CONNECT;
+  if (msg) {
+      res = msg->data.result;
+  }
+  curl_multi_cleanup(multi_handle);
+
+  if (res != CURLE_OK) {
+      return 0;
+  }
+
+  return 1;
+}
+
+int postPerform()
+{
+  if (file_handle) {
+    fclose(file_handle);
+    file_handle = NULL;
+  }
+  return 1;
+}
+
+int getResponse()
+{
+  int response_code = 0;
+  curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE, &response_code);
+
+  if (response_code != 200) {
+      return 0;
+  }
+  return 1;
+}
+
+static int checkCrlUriFormat(const char* uri)
+{
+  if (!uri) {
+      return 0;
+  }
+  uint32_t uri_len = strnlen(uri, CURL_URI_LENGTH_MAX + 1);
+  if ((uri_len > CURL_URI_LENGTH_MAX) ||
+      (uri_len < CURL_URI_LENGTH_MIN)) {
+      return 0;
+  }
+  if (0 != strncmp("http", uri, (CURL_URI_LENGTH_MIN - 1))) {
+      return 0;
+  }
+  return 1;
+}
+
+static void getCrlUri(STACK_OF(GENERAL_NAME)* *names, CrlUriInfo* crl_uri_info)
+{
+  while (sk_GENERAL_NAME_num(names) > 0) {
+    GENERAL_NAME *name = sk_GENERAL_NAME_pop(names);
+    if (!name) {
+      break;
+    }
+    if (name->type != GEN_URI) {
+      continue;
+    }
+    ASN1_IA5STRING *uri = name->d.uniformResourceIdentifier;
+    if (checkCrlUriFormat((char*)(uri->data))) {
+      strncpy(crl_uri_info->crl_uri, (char*)(uri->data), CURL_URI_LENGTH_MAX);
+      crl_uri_info->is_uri_valid = 1;
+      break;
+    }
+  }
+}
+
+static int getFileByHttp(const char* url, const char *path)
+{
+  easy_handle = curl_easy_init();
+  int result = setOption(url);
+  if (result) {
+    result = doPerform(path);
+  }
+  if (easy_handle) {
+    curl_easy_cleanup(easy_handle);
+  }
+  return result;
+}
+
+/*
+  return ret
+  0: CRL update Failed.
+  1: DIST_POINT not include in Server Cert.
+  2: CRL update Success.
+*/
+static int tls_crl_update(X509* *tmp_cert)
+{
+  CrlUriInfo *crl_uri_info = (CrlUriInfo*)malloc(sizeof(CrlUriInfo));
+  crl_uri_info->is_uri_valid = 0;
+  int ret = 0;
+  int crl_exist = 0;
+
+  STACK_OF(DIST_POINT)* dist_point = (STACK_OF(DIST_POINT)*)(
+          X509_get_ext_d2i(tmp_cert, NID_crl_distribution_points, NULL, NULL));
+  while (sk_DIST_POINT_num(dist_point) > 0) {
+    crl_exist = 1;
+    DIST_POINT *dp = sk_DIST_POINT_pop(dist_point);
+    if (!dp) {
+      break;
+    }
+    STACK_OF(GENERAL_NAME)* names = dp->distpoint->name.fullname;
+    getCrlUri(names, crl_uri_info);
+    sk_GENERAL_NAME_free(names);
+    if (crl_uri_info->is_uri_valid) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info]CRL Get URL [%s]", crl_uri_info->crl_uri);
+        int ret_crl = getFileByHttp(crl_uri_info->crl_uri, CRL_PATH);
+        if(ret_crl == 1) {
+            ret = 1;
+            FILE* CRL_TMP = fopen(CRL_PATH, "rb");
+            if (CRL_TMP) {
+                X509_CRL *d2i_crl = NULL;
+                d2i_crl = d2i_X509_CRL_fp(CRL_TMP, NULL);
+                if (d2i_crl) {
+                    FILE* CRL_CNV = fopen(CRL_TMP_CNV, "wb");
+                    if (CRL_CNV) {
+                        if(PEM_write_X509_CRL(CRL_CNV, d2i_crl)) {
+                            fclose(CRL_CNV);
+                        }
+                    }
+                }
+                else{
+                  rename(CRL_PATH, CRL_TMP_CNV);
+                }
+                fclose(CRL_TMP);
+            }
+            break;
+        } else if(ret_crl == 2) {
+            ret = 2;
+            break;
+        }
+    }
+  }
+  free(crl_uri_info);
+  sk_DIST_POINT_free(dist_point);
+    WRITE_LOG("test %d", ret);
+  if (crl_exist == 0) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+        "[tls.info]CRL not found DIST_POINT");
+    ret = 2;
+  }
+  return ret;
+}
+
+static int tls_verify_crl(STACK_OF(x509) *x509_cert) {
+  register int i = 0;
+  X509_NAME *subject = NULL, *issuer = NULL;
+  STACK_OF(X509_CRL) *crls = NULL;
+  X509_STORE_CTX *store_ctx = NULL;
+  X509_STORE *tls_crl_store = NULL;
+  X509 *ca_cert             = NULL;
+  X509 *xs                  = NULL;
+  int n, res;
+  X509 *root_cert           = NULL;
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL num[%d]", __LINE__, sk_X509_num(x509_cert));
+  if (sk_X509_num(x509_cert) <= 0) {
+    return 1;
+  }
+  tls_crl_store = X509_STORE_new();
+  if (tls_crl_store == NULL) {
+    return -1;
+  }
+   /* Load CA Cert Path */
+  config_rec *c = find_config(main_server->conf, CONF_PARAM, "ProxyTLSCACertificateFile", FALSE);
+  if (c == NULL) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL load CA Cert failed.", __LINE__);
+    return -1;
+  }
+  BIO* bio = BIO_new(BIO_s_file());
+  if (bio == NULL) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL BIO failed.", __LINE__);
+    return -1;
+  }
+
+  issuer = X509_get_issuer_name(sk_X509_value(x509_cert, sk_X509_num(x509_cert) - 1));
+  for (int index = 0; index < sk_X509_num(x509_cert); ++index) {
+    /* Update CRL */
+    xs = sk_X509_value(x509_cert, index);
+    if (!X509_NAME_cmp(issuer,X509_get_subject_name(xs))) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info]CRL Target is root cert index[%d]", index);
+      break;
+    }
+    int get_crl = tls_crl_update(xs);
+    if (get_crl == 0) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info]CRL Update failed index[%d]", index);
+      return -1;
+    } else if (get_crl == 2){
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info]CRL No Update index[%d]", index);
+      continue;
+    }
+    subject = X509_get_issuer_name(sk_X509_value(x509_cert, index));
+    /* Load CRL */
+    X509_STORE_load_locations(tls_crl_store, CRL_TMP_CNV, NULL);
+    if (!tls_crl_store) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info]CRL Load failed");
+      X509_STORE_free(tls_crl_store);
+      return -1;
+    }
+
+    store_ctx = X509_STORE_CTX_new();
+    if (X509_STORE_CTX_init(store_ctx, tls_crl_store, NULL, NULL) <= 0) {
+      tls_log("error initializing CRL store context: %s", proxy_tls_get_errors());
+      X509_STORE_CTX_free(store_ctx);
+      X509_STORE_free(tls_crl_store);
+      return -1;
+    }
+    /* Check CRL */
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL index[%d]", __LINE__, index);
+    crls = X509_STORE_CTX_get1_crls(store_ctx, issuer);
+    if (crls == NULL) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL no crls by issuer", __LINE__);
+      crls = X509_STORE_CTX_get1_crls(store_ctx, subject);
+    }
+    if (crls != NULL) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL index[%d]", __LINE__, index);
+      for (i = 0; i < sk_X509_CRL_num(crls); i++) {
+        X509_CRL *crl = NULL;
+        EVP_PKEY *pubkey;
+        char buf[512];
+        int len;
+        int is_signature = 0;
+        BIO *b = BIO_new(BIO_s_mem());
+
+        crl = sk_X509_CRL_value(crls, i);
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL i[%d]", __LINE__, i);
+        BIO_printf(b, "CA CRL: Issuer: ");
+        X509_NAME_print(b, issuer, 0);
+        BIO_printf(b, ", lastUpdate: ");
+        ASN1_UTCTIME_print(b, X509_CRL_get0_lastUpdate(crl));
+        BIO_printf(b, ", nextUpdate: ");
+        ASN1_UTCTIME_print(b, X509_CRL_get0_nextUpdate(crl));
+
+        len = BIO_read(b, buf, sizeof(buf) - 1);
+        if ((size_t) len >= sizeof(buf)) {
+          len = sizeof(buf)-1;
+        }
+        buf[len] = '\0';
+
+        BIO_free(b);
+        tls_log("%s", buf);
+        // check CRL file by  certificate
+        /* Load CA Cert */
+        if (BIO_read_filename(bio, c->argv[0]) <= 0) {
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL CA cert load failed", __LINE__);
+          BIO_free_all(bio);
+          return -1;
+        }
+        for (int check_crl = 0; check_crl < sk_X509_CRL_num(crls); check_crl++) {
+          crl = sk_X509_CRL_value(crls, check_crl);
+          root_cert = sk_X509_value(x509_cert, index + 1);
+          pubkey = X509_get_pubkey(root_cert);
+          /* Verify the signature on this CRL */
+          res = X509_CRL_verify(crl, pubkey);
+          if (pubkey) {
+            EVP_PKEY_free(pubkey);
+          }
+
+          if (res <= 0) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+            "[tls.info][%d]CRL invalid signature on CRL [%s]", __LINE__, proxy_tls_get_errors());
+          } else {
+            is_signature = 1;
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL signature OK", __LINE__);
+            break;
+          }
+          if (!is_signature) {
+            root_cert = sk_X509_value(x509_cert, sk_X509_num(x509_cert) - 1);
+            pubkey = X509_get_pubkey(root_cert);
+            /* Verify the signature on this CRL */
+            res = X509_CRL_verify(crl, pubkey);
+            if (pubkey) {
+              EVP_PKEY_free(pubkey);
+            }
+
+            if (res <= 0) {
+              (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+              "invalid signature on CRL [%s]", proxy_tls_get_errors());
+            } else {
+              is_signature = 1;
+              (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL signature OK", __LINE__);
+              break;
+            }
+          }
+          if (!is_signature) {
+            root_cert = PEM_read_bio_X509(bio, NULL, 0, NULL);
+            pubkey = X509_get_pubkey(root_cert);
+            /* Verify the signature on this CRL */
+            res = X509_CRL_verify(crl, pubkey);
+            if (pubkey) {
+              EVP_PKEY_free(pubkey);
+            }
+
+            if (res <= 0) {
+              (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+              "[tls.info][%d]CRL invalid signature on CRL [%s]", __LINE__, proxy_tls_get_errors());
+            } else {
+              is_signature = 1;
+              (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL signature OK", __LINE__);
+              break;
+            }
+          }
+        }
+        if (!is_signature) {
+          sk_X509_CRL_free(crls);
+          X509_STORE_CTX_cleanup(store_ctx);
+          X509_STORE_CTX_free(store_ctx);
+          X509_STORE_free(tls_crl_store);
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+          "[tls.info][%d]CRL invalid signature on CRL ALL [%s]", __LINE__, proxy_tls_get_errors());
+          return FALSE;
+        }
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL", __LINE__);
+        /* Check date of CRL to make sure it's not expired */
+        res = X509_cmp_current_time(X509_CRL_get0_nextUpdate(crl));
+
+        if (res == 0) {
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[tls.info][%d]CRL update time err.", __LINE__);
+          tls_log("CRL has invalid nextUpdate field: %s", proxy_tls_get_errors());
+          sk_X509_CRL_free(crls);
+          X509_STORE_CTX_cleanup(store_ctx);
+          X509_STORE_CTX_free(store_ctx);
+          X509_STORE_free(tls_crl_store);
+          return FALSE;
+        }
+        if (res < 0) {
+          /* XXX This is a bit draconian, rejecting all certificates if the CRL
+           * has expired.  See also Bug#3216, about automatically reloading
+           * the CRL file when it has expired.
+           */
+          tls_log("%s", "CRL is expired, revoking all certificates until an "
+            "updated CRL is obtained");
+          sk_X509_CRL_free(crls);
+          X509_STORE_CTX_cleanup(store_ctx);
+          X509_STORE_CTX_free(store_ctx);
+          X509_STORE_free(tls_crl_store);
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info]CRL has expired: %s", proxy_tls_get_errors());
+          return FALSE;
+        }
+      }
+    }
+    else {
+        sk_X509_CRL_free(crls);
+        X509_STORE_CTX_free(store_ctx);
+        X509_STORE_free(tls_crl_store);
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[tls.info][%d]CRL is none", __LINE__);
+        return FALSE;
+    }
+    /* Try to retrieve a CRL corresponding to the _issuer_ of
+     * the current certificate in order to check for revocation.
+     */
+    if (crls != NULL) {
+      for (i = 0; i < sk_X509_CRL_num(crls); i++) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL", __LINE__);
+        register int j;
+        X509_CRL *crl;
+        crl = sk_X509_CRL_value(crls, i);
+        /* Check if the current certificate is revoked by this CRL */
+        n = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
+        for (j = 0; j < n; j++) {
+          X509_REVOKED *revoked;
+          const ASN1_INTEGER *sn;
+          revoked = sk_X509_REVOKED_value(X509_CRL_get_REVOKED(crl), j);
+          if (revoked == NULL) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]CRL no revoked cert", __LINE__);
+            continue;
+          }
+          sn = X509_REVOKED_get0_serialNumber(revoked);
+          if (ASN1_INTEGER_cmp(sn, X509_get_serialNumber(xs)) == 0) {
+            long serial = ASN1_INTEGER_get(sn);
+            char *cp = tls_x509_name_oneline(issuer);
+
+            tls_log("certificate with serial number %ld (0x%lX) revoked per CRL "
+              "from issuer '%s'", serial, serial, cp ? cp : "(ERROR)");
+            sk_X509_CRL_free(crls);
+            X509_STORE_CTX_cleanup(store_ctx);
+            X509_STORE_CTX_free(store_ctx);
+            X509_STORE_free(tls_crl_store);
+              (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[tls.info]certificate with serial number %ld (0x%lX) revoked per CRL "
+              "from issuer '%s'", serial, serial, cp ? cp : "(ERROR)");
+            return FALSE;
+          }
+        }
+      }
+    }
+  }
+  if (crls) {
+    sk_X509_CRL_free(crls);
+  }
+  if (store_ctx) {
+    X509_STORE_CTX_cleanup(store_ctx);
+    X509_STORE_CTX_free(store_ctx);
+  }
+  X509_STORE_free(tls_crl_store);
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d]CRL ", __LINE__);
+  return 1;
+}
+
+void saveIntermediateCertification(int num)
+{
+  if (num > MAX_INTERMEDIATE_CERT_NUM) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d]CRL ", __LINE__);
+    return;
+  }
+  // Save Intermediate Certification
+  char cert_path[64] = "";
+  snprintf(cert_path, 64, "/tmp/ftp_inter_tmp%d.crt", num);
+
+  FILE *cert_fwp = fopen(cert_path, "wb");
+  FILE *cert_frp = fopen(TMP_INTER_CERT_FILE, "rb");
+  int ret = 1;  
+  if (NULL != cert_fwp && NULL != cert_frp) {
+    char *buf = (char*)(calloc(TMP_BUF_SIZE, 1));
+    if (NULL != buf) {
+      uint32_t size;
+      while (TMP_BUF_SIZE == (size = fread(buf, 1, TMP_BUF_SIZE, cert_frp))) {
+        if (fwrite(buf, 1, size, cert_fwp) != size) {
+          ret = 0;
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+          break;
+        }
+      }
+      if (ret) {
+        // check end of file
+        if (0 != feof(cert_frp)) {
+          if (fwrite(buf, 1, size, cert_fwp) != size) {
+            ret = 0;
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+          }
+        }
+        else {
+        // read error
+          ret = 0;
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+        }
+      }
+      free(buf);
+    }
+    else {
+      ret = 0;
+    }
+    if (NULL != cert_frp) {
+      fclose(cert_frp);
+    }
+    else {
+      ret = 0;
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+    }
+    if (NULL != cert_fwp) {
+      fclose(cert_fwp);
+    }
+    else {
+      ret= 0;
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+    }
+  }
+  else {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+  }
+}
+
+static int appendIa5String(STACK_OF(OPENSSL_STRING) **ssl_strings, ASN1_IA5STRING *asn_string)
+{
+    if (asn_string->type != V_ASN1_IA5STRING)
+        return 1;
+
+    if (!asn_string->data || !asn_string->length)
+        return 1;
+
+    if (!*ssl_strings)
+        *ssl_strings = sk_OPENSSL_STRING_new(skStrCmpMethod);
+
+    if (!*ssl_strings)
+        return 0;
+
+    if (sk_OPENSSL_STRING_find(*ssl_strings, (char *)asn_string->data) != -1)
+        return 1;
+
+    char *emtmp = BUF_strdup((char *)asn_string->data);
+    if (!emtmp || !sk_OPENSSL_STRING_push(*ssl_strings, emtmp)) {
+        X509_email_free(*ssl_strings);
+        *ssl_strings = NULL;
+        return 0;
+    }
+    return 1;
+}
+
+static STACK_OF(OPENSSL_STRING) *X509GetCaIssuers(X509 *x509)
+{
+    AUTHORITY_INFO_ACCESS *info;
+    STACK_OF(OPENSSL_STRING) *ret = NULL;
+
+    info = (AUTHORITY_INFO_ACCESS *)X509_get_ext_d2i(x509, NID_info_access, NULL, NULL);
+    if (!info) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      return ret;
+    }
+    for (int i = 0; i < sk_ACCESS_DESCRIPTION_num(info); i++) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+        ACCESS_DESCRIPTION *ad = sk_ACCESS_DESCRIPTION_value(info, i);
+        if (OBJ_obj2nid(ad->method) == NID_ad_ca_issuers) {
+            if (ad->location->type == GEN_URI) {
+                if (!appendIa5String(&ret, ad->location->d.uniformResourceIdentifier))
+                    break;
+            }
+        }
+    }
+    AUTHORITY_INFO_ACCESS_free(info);
+    return ret;
+}
+
+static int storeCaCert(X509_STORE_CTX *x509_ctx, int num)
+{
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] sk_num[%d]", __LINE__, OPENSSL_sk_num(X509_STORE_CTX_get0_untrusted(x509_ctx)));
+  static char caIssuerUri[STR_CRL_URI_LENGTH_MAX];
+
+  X509* tCert = OPENSSL_sk_value(X509_STORE_CTX_get0_untrusted(x509_ctx),
+                              OPENSSL_sk_num(X509_STORE_CTX_get0_untrusted(x509_ctx)) - 1);
+  STACK_OF(OPENSSL_STRING) *caIssuer = X509GetCaIssuers(tCert);
+  if (caIssuer)
+  {
+    char* tmp = sk_OPENSSL_STRING_value(caIssuer, 0);
+    memset(caIssuerUri, 0, STR_CRL_URI_LENGTH_MAX);
+    strncpy(caIssuerUri, tmp, STR_CRL_URI_LENGTH_MAX-1);
+    X509_email_free(caIssuer);
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] [CA Issuers] url: %s", __LINE__, caIssuerUri);
+  }
+  else {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+    return 0;
+  }
+
+  if (!caIssuerUri[0]) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+    return 0;
+  }
+
+  // download intermediate certificate
+  uint64_t write_file_size = 0;
+
+  int ret = getFileByHttp(caIssuerUri, TMP_INTER_CERT_FILE);
+  if (!ret) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] failed caIssuerUri: %s, ret=%d",
+                              __LINE__, caIssuerUri, ret);
+      return 0;
+  }
+
+  // Read tmp intermidiate certificate
+  BIO* bio_file = BIO_new_file(TMP_INTER_CERT_FILE, "r");
+  if (NULL == bio_file) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      return 0;
+  }
+
+  X509* newCert = PEM_read_bio_X509(bio_file, NULL, NULL, NULL);
+  if (!newCert)
+  {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+    BIO_free(bio_file);
+    bio_file = NULL;
+
+    bio_file = BIO_new_file(TMP_INTER_CERT_FILE, "r");
+    if (!bio_file) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      return 0;
+    }
+
+    newCert = d2i_X509_bio(bio_file, NULL);
+    if (!newCert) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      BIO_free(bio_file);
+      int rvFileRes = remove(TMP_INTER_CERT_FILE);
+      if (0 != rvFileRes) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      }
+      return 0;
+    }
+  }
+
+  BIO_free(bio_file);
+
+  saveIntermediateCertification(num);
+
+  int rvFileRes = remove(TMP_INTER_CERT_FILE);
+  if(0 != rvFileRes) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+  }
+
+  if (0 != sk_X509_push(X509_STORE_CTX_get0_untrusted(x509_ctx), newCert)) {
+    X509_STORE_CTX_init(x509_ctx,
+                        X509_STORE_CTX_get0_store(x509_ctx),
+                        X509_STORE_CTX_get0_cert(x509_ctx),
+                        X509_STORE_CTX_get0_untrusted(x509_ctx));
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+  }
+  else {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+    return 0;
+  }
+  return 1;
+}
+
+static int get_issuer_cert_locally(X509_STORE_CTX *ctx)
+{
+  time_t now;
+  int ret = 0;
+  int err, num;
+  now = time(NULL);
+  num = 0;
+  err = X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY;
+  do {
+      if (1 == ret)
+      {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      }
+      else if (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY ||
+               err == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN)
+      {
+        num++;
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] num[%d]", __LINE__, num);
+          if (!storeCaCert(ctx, num)){
+              // Delete the temporary intermediate certification file if it remains
+              if (0 == access(TMP_INTER_CERT_FILE, F_OK)) {
+                  if(0 != remove(TMP_INTER_CERT_FILE)) {
+                      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+                  }
+                  else {
+                      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+                  }
+              }
+              break;
+          }
+          X509_STORE_CTX_set_time(ctx, 0, now);
+          ret = X509_verify_cert(ctx);
+          err = X509_STORE_CTX_get_error(ctx);
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ret[%d] err[%d]", __LINE__, ret, err);
+          continue;
+      }
+      else
+      {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+      }
+      break;
+  } while(1);
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ret[%d] err[%d]", __LINE__, ret, err);
+  return ret;
+}
+
 static int tls_verify_cb(int ok, X509_STORE_CTX *ctx) {
   X509 *cert;
 
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ok[%d]", __LINE__, ok);
   cert = X509_STORE_CTX_get_current_cert(ctx);
 
   if (!ok) {
@@ -1163,6 +1975,7 @@ static int tls_verify_cb(int ok, X509_ST
 #else
     verify_error = ctx->error;
 #endif /* OpenSSL-1.1.x and later */
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] verify_error[%d]", __LINE__, verify_error);
     switch (verify_error) {
       case X509_V_ERR_CERT_CHAIN_TOO_LONG:
       case X509_V_ERR_CERT_NOT_YET_VALID:
@@ -1170,7 +1983,6 @@ static int tls_verify_cb(int ok, X509_ST
       case X509_V_ERR_CERT_REVOKED:
       case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
       case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
-      case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
       case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
       case X509_V_ERR_APPLICATION_VERIFICATION:
         (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
@@ -1178,7 +1990,11 @@ static int tls_verify_cb(int ok, X509_ST
           X509_verify_cert_error_string(verify_error));
         ok = 0;
         break;
-
+      case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ", __LINE__);
+        ok = get_issuer_cert_locally(ctx);
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d] ok[%d]", __LINE__, ok);
+        break;
       case X509_V_ERR_INVALID_PURPOSE: {
         register int i;
         int count = X509_PURPOSE_get_count();
@@ -1395,7 +2211,7 @@ static int tls_connect(conn_t *conn, con
 
 # if defined(TLSEXT_STATUSTYPE_ocsp)
   pr_trace_msg(trace_channel, 9, "requesting stapled OCSP response");
-  SSL_set_tlsext_status_type(ssl, TLSEXT_STATUSTYPE_ocsp);
+  // SSL_set_tlsext_status_type(ssl, TLSEXT_STATUSTYPE_ocsp);
 # endif /* OCSP support */
 #endif /* OPENSSL_NO_TLSEXT */
 
@@ -1550,6 +2366,42 @@ static int tls_connect(conn_t *conn, con
 
     return -3;
   }
+  // Check OCSP
+  int ok = check_cert_ocsp(ssl);
+  if (ok != 1 && ok != 2) {
+      // check ng
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OSCP Check NG ret[%d]", __LINE__, ok);
+      return -1;
+  }
+  // Check CRL
+  STACK_OF(x509) *x509_cert = SSL_get0_verified_chain(ssl);
+  if (ok != 1) {
+    ok = tls_verify_crl(x509_cert);
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[tls.info][%d] func[%s]", __LINE__, __func__);
+    if (ok != 1) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        if (NULL != x509_cert) {
+          x509_cert = NULL;
+        }
+        return -1;
+    }
+  }
+  if (NULL != x509_cert) {
+    x509_cert = NULL;
+  }
+  // Check Server Cert
+  subj = tls_get_subj_name(ssl);
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[tls.info][%d] func[%s]", __LINE__, __func__);
+  if (subj != NULL) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
+      "Server: %s", subj);
+  }
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[tls.info][%d] func[%s]", __LINE__, __func__);
+  if (check_server_cert(ssl, conn, host_name) < 0) {
+    tls_end_sess(ssl, nstrm->strm_type, 0);
+    return -1;
+  }
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[tls.info][%d] func[%s]", __LINE__, __func__);
 
   /* Disable the handshake timer. */
   pr_timer_remove(handshake_timer_id, &proxy_module);
@@ -1607,16 +2459,6 @@ static int tls_connect(conn_t *conn, con
     tls_ctrl_ssl = ssl;
   }
 
-  subj = tls_get_subj_name(ssl);
-  if (subj != NULL) {
-    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
-      "Server: %s", subj);
-  }
-
-  if (check_server_cert(ssl, conn, host_name) < 0) {
-    tls_end_sess(ssl, nstrm->strm_type, 0);
-    return -1;
-  }
 
   (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
     "%s connection created, using cipher %s (%d bits)",
@@ -2178,6 +3020,471 @@ static unsigned int tls_psk_cb(SSL *ssl,
 #endif /* PSK support */
 
 #if !defined(OPENSSL_NO_TLSEXT) && defined(TLSEXT_STATUSTYPE_ocsp)
+void releaseResourceResponder(BIO **bio, OCSP_RESPONSE **ocsp_resp, OCSP_BASICRESP **ocsp_basic_resp)
+{
+    // release
+    if (NULL != *ocsp_resp) {
+        OCSP_RESPONSE_free(*ocsp_resp);
+        *ocsp_resp = NULL;
+    }
+    if (NULL != *ocsp_basic_resp) {
+        OCSP_BASICRESP_free(*ocsp_basic_resp);
+        *ocsp_basic_resp = NULL;
+    }
+    if (NULL != *bio) {
+        BIO_free_all(*bio);
+        *bio = NULL;
+    }
+    return;
+}
+
+OCSP_RESPONSE * queryResponder(BIO *err, BIO *cbio, char *path,
+                char *host, OCSP_REQUEST *req, int req_timeout)
+{
+    int fd, rv;
+    OCSP_REQ_CTX *ctx = NULL;
+    OCSP_RESPONSE *rsp = NULL;
+    fd_set confds;
+    struct timeval tv;
+
+    if (req_timeout != -1) {
+        BIO_set_nbio(cbio, 1);
+    }
+
+    rv = BIO_do_connect(cbio);
+
+    if ((rv <= 0) && ((req_timeout == -1) || !BIO_should_retry(cbio))) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        return NULL;
+    }
+
+    if (BIO_get_fd(cbio, &fd) <= 0) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        return NULL;
+    }
+
+    if (req_timeout != -1 && rv <= 0) {
+        FD_ZERO(&confds);
+        FD_SET(fd, &confds);
+        tv.tv_usec = 0;
+        tv.tv_sec = req_timeout;
+        rv = select(fd + 1, NULL, &confds, NULL, &tv);
+        if (rv == 0) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            return NULL;
+        }
+    }
+
+    ctx = OCSP_sendreq_new(cbio, path, NULL, -1);
+    if (!ctx) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        return NULL;
+    }
+
+    if (!OCSP_REQ_CTX_add1_header(ctx, "Host", host)) {
+        if (ctx) {
+            OCSP_REQ_CTX_free(ctx);
+        }
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        return NULL;
+    }
+
+    if (!OCSP_REQ_CTX_set1_req(ctx, req)) {
+        if (ctx) {
+            OCSP_REQ_CTX_free(ctx);
+        }
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        return NULL;
+    }
+
+    for (;;) {
+        rv = OCSP_sendreq_nbio(&rsp, ctx);
+        if (rv != -1) {
+            break;
+        }
+        if (req_timeout == -1) {
+            continue;
+        }
+        FD_ZERO(&confds);
+        FD_SET(fd, &confds);
+        tv.tv_usec = 0;
+        tv.tv_sec = req_timeout;
+        if (BIO_should_read(cbio)) {
+            rv = select(fd + 1, &confds, NULL, NULL, &tv);
+        } else if (BIO_should_write(cbio)) {
+            rv = select(fd + 1, NULL, &confds, NULL, &tv);
+        } else {
+            if (ctx) {
+                OCSP_REQ_CTX_free(ctx);
+            }
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            return NULL;
+        }
+
+        if (rv == 0) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            break;
+        }
+        if (rv == -1) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            break;
+         }
+    }
+
+    return rsp;
+}
+
+OCSP_RESPONSE *sendRequestOcsp(BIO *err, OCSP_REQUEST *req,
+            char *host, char *path, char *port, int use_ssl, int req_timeout)
+{
+    BIO *cbio = NULL;
+    OCSP_RESPONSE *resp = NULL;
+    cbio = BIO_new_connect(host);
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP---------------- host[%s]", __LINE__,host);
+    if (cbio && port && use_ssl == 0) {
+        BIO_set_conn_port(cbio, port);
+        resp = queryResponder(err, cbio, path, host, req, req_timeout);
+    }
+    if (cbio) {
+        BIO_free_all(cbio);
+    }
+    if (!resp) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        return NULL;
+    }
+    return resp;
+}
+
+int32_t parseResponseOcsp(OCSP_RESPONSE *ocsp_resp, OCSP_BASICRESP **ocsp_basic_resp)
+{
+    int ocsp_status = 0;
+    int32_t responder_status = OCSP_response_status(ocsp_resp);
+
+    switch (responder_status) {
+    case OCSP_RESPONSE_STATUS_SUCCESSFUL:
+        *ocsp_basic_resp = OCSP_response_get1_basic(ocsp_resp);
+        if (NULL == ocsp_basic_resp) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        } else {
+            ocsp_status = 1;
+        }
+        break;
+    case OCSP_RESPONSE_STATUS_MALFORMEDREQUEST:
+    case OCSP_RESPONSE_STATUS_INTERNALERROR:
+    case OCSP_RESPONSE_STATUS_TRYLATER:
+    case OCSP_RESPONSE_STATUS_SIGREQUIRED:
+    case OCSP_RESPONSE_STATUS_UNAUTHORIZED:
+    default:
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] ocsp_status[%d]", __LINE__, responder_status);
+        break;
+    }
+
+    return ocsp_status;
+}
+
+int32_t ocsp_verify_load_cert(OCSP_BASICRESP *ocsp_basic_resp, STACK_OF(X509) *issuers, int64_t resp_verify_flags, X509_STORE *cert_store)
+{
+    if (cert_store == NULL) {
+      return 0;
+    }
+    config_rec *c = find_config(main_server->conf, CONF_PARAM, "ProxyTLSCACertificateFile", FALSE);
+    if (c == NULL) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      return 0;
+    }
+    BIO* bio = BIO_new(BIO_s_file());
+    if (bio == NULL) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      return 0;
+    }
+    if (BIO_read_filename(bio, c->argv[0]) <= 0) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      BIO_free_all(bio);
+      return 0;
+    }
+    X509 *ca_cert = NULL;
+    while ((ca_cert = PEM_read_bio_X509(bio, NULL, 0, NULL))) {
+      if (1 != (X509_STORE_add_cert(cert_store, ca_cert))) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      }
+      X509_free(ca_cert);
+      ca_cert = NULL;
+    }
+    int ret = OCSP_basic_verify(ocsp_basic_resp, issuers, cert_store, resp_verify_flags);
+    BIO_free_all(bio);
+    return ret;
+}
+int32_t verifyResponseOcsp(OCSP_CERTID *cert_id, OCSP_BASICRESP *ocsp_basic_resp, X509 *issuer_cert, STACK_OF(X509) *interm_certs, X509 *root_cert)
+{
+    int32_t ret = 0;
+    int64_t resp_verify_flags = 0;
+
+    STACK_OF(X509) *issuers = NULL;
+    X509_STORE *cert_store = NULL;
+    int32_t status = V_OCSP_CERTSTATUS_UNKNOWN;
+    int32_t reason = 0;
+
+    resp_verify_flags = OCSP_NOINTERN | OCSP_TRUSTOTHER;
+
+    issuers = sk_X509_new_null();
+    if (issuers == NULL) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      return ret;
+    }
+    if (!sk_X509_push(issuers, issuer_cert)) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      sk_X509_free(issuers);
+      return ret;
+    }
+    STACK_OF(X509) *root_certs = sk_X509_new_null();
+    if (root_certs == NULL) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      return ret;
+    }
+    if (!sk_X509_push(root_certs, root_cert)) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      sk_X509_free(root_certs);
+      return ret;
+    }
+    do {
+      int32_t is_status = OCSP_basic_verify(ocsp_basic_resp, issuers, NULL, resp_verify_flags);
+      if (1 == is_status) {
+        // OK
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+      }
+      else {
+        int32_t is_status = OCSP_basic_verify(ocsp_basic_resp, root_certs, NULL, resp_verify_flags);
+        if (1 == is_status) {
+          // OK
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+        }
+        else {
+          // fatal error
+          resp_verify_flags = 0;
+          int result = 0;
+          cert_store = X509_STORE_new();
+          if (NULL == cert_store) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            break;
+          }
+          X509_VERIFY_PARAM* prm = X509_VERIFY_PARAM_new();
+          if (NULL == prm) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            X509_STORE_free(cert_store);
+            break;
+          }
+          time_t now = time(NULL);
+          X509_VERIFY_PARAM_set_time(prm, now);
+          if (1 != X509_STORE_set1_param(cert_store, prm)) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            X509_STORE_free(cert_store);
+            break;
+          }
+          if (1 != (X509_STORE_add_cert(cert_store, root_cert))) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            X509_STORE_free(cert_store);
+            break;
+          }
+          if (NULL == interm_certs) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            result = OCSP_basic_verify(ocsp_basic_resp, issuers, cert_store, resp_verify_flags);
+            if (1 != result) {
+              (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+              result = ocsp_verify_load_cert(ocsp_basic_resp, issuers, resp_verify_flags, cert_store);
+            }
+          } else {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            result = OCSP_basic_verify(ocsp_basic_resp, interm_certs, cert_store, resp_verify_flags);
+          }
+          if (1 == result) {
+            //success
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+          } else {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+            break;
+          }
+          X509 *responder_cert = NULL;
+          if (1 != (OCSP_resp_get0_signer(ocsp_basic_resp, &responder_cert, NULL))) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] ret[%d]", __LINE__, ret);
+            break;
+          }
+          if (NULL == (X509_get_ext_d2i(responder_cert, NID_id_pkix_OCSP_noCheck, NULL, NULL))) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] ret[%d]", __LINE__, ret);
+            break;
+          }
+          //X509_STORE_free(cert_store);
+        }
+      }
+
+      is_status = OCSP_resp_find_status(ocsp_basic_resp, cert_id, &status, NULL, NULL, NULL, NULL); 
+      if (is_status != 1) {
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] is_status[%d]", __LINE__, is_status);
+          break;
+      }
+
+      switch (status) {
+        case V_OCSP_CERTSTATUS_REVOKED:
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP cert revoled", __LINE__);
+          break;
+        case V_OCSP_CERTSTATUS_UNKNOWN:
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP cert Unknown", __LINE__);
+          break;
+        case V_OCSP_CERTSTATUS_GOOD:
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+          ret = 1;
+          break;
+        default:
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]", __LINE__);
+          break;
+      }
+    } while(0);
+
+    sk_X509_free(issuers);
+    sk_X509_free(root_certs);
+    if (cert_store) {
+      X509_STORE_free(cert_store);
+    }
+
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] ret[%d]", __LINE__, ret);
+    return ret;
+}
+
+int verify_ocsp_start(X509 *target_cert, X509 *issuer_cert, STACK_OF(X509) *interm_certs, X509 *root_cert)
+{
+  int ret = 0;
+  // OCSP Request create
+  OCSP_REQUEST *ocsp_req = OCSP_REQUEST_new();
+  const EVP_MD *evp_md = EVP_sha1();
+  OCSP_CERTID *cert_id = OCSP_cert_to_id(evp_md, target_cert, issuer_cert);
+  if (!OCSP_request_add0_id(ocsp_req, cert_id)) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP add request ID failed.", __LINE__);
+    return ret;
+  }
+  
+  // get OCSP URL
+  STACK_OF(OPENSSL_STRING) *resp_url_list = X509_get1_ocsp(target_cert);
+  if (resp_url_list == NULL) {
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP resp_url_list none.", __LINE__);
+    return ret;
+  }
+  int list_num = sk_OPENSSL_STRING_num(resp_url_list);
+  BIO *bio_err = BIO_new_fp(stderr, BIO_NOCLOSE|BIO_FP_TEXT);
+  OCSP_BASICRESP *ocsp_basic_resp = NULL;
+  OCSP_RESPONSE *resp             = NULL;
+  for (int j = 0; j < list_num; j++) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP url list target[%d]", __LINE__, j);
+      char *host = NULL, *port = NULL, *path = NULL; 
+      int use_ssl, req_timeout = 30;
+      char *ocsp_url = sk_OPENSSL_STRING_value(resp_url_list, j);
+      if (OCSP_parse_url(ocsp_url, &host, &port, &path, &use_ssl) && !use_ssl) {
+          //send OCSP request
+          resp = sendRequestOcsp(bio_err, ocsp_req, host, path, port, use_ssl, req_timeout);
+          if (!resp) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP resp null.", __LINE__);
+            continue;
+          }
+          //see crypto/ocsp/ocsp_prn.c for examples parsing OCSP responses
+          int responder_status = OCSP_response_status(resp);
+          if (responder_status != OCSP_RESPONSE_STATUS_SUCCESSFUL) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP resp is not SUCCESSFUL. status[%d]", __LINE__, responder_status);
+            continue;
+          }
+          // parse OCSP resp
+          int is_ocsp_success = parseResponseOcsp(resp, &ocsp_basic_resp);
+          if (is_ocsp_success != 1) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP resp parse failed. status[%d] parse[%d]", __LINE__, responder_status, is_ocsp_success);
+            continue;
+          }
+          // verify check OCSP resp
+          if (!verifyResponseOcsp(cert_id, ocsp_basic_resp, issuer_cert, interm_certs, root_cert)) {
+            (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP verify failed", __LINE__);
+            continue;
+          }
+          ret = 1;
+          OPENSSL_free(host);
+          OPENSSL_free(path);
+          OPENSSL_free(port);
+          break;
+      }
+  }
+  (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP verify ret[%d]", __LINE__, ret);
+  releaseResourceResponder(&bio_err, &resp, &ocsp_basic_resp);
+  return ret;
+}
+
+int checkOCSPSupport(X509 *target_cert)
+{
+    int ret = 0;
+    if (NULL == target_cert) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP no target cert", __LINE__);
+        return ret;
+    }
+    STACK_OF(OPENSSL_STRING) *resp_url_list = X509_get1_ocsp(target_cert); 
+    if(NULL != resp_url_list) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP Support", __LINE__);
+        ret = 1;
+    } else {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP not Support", __LINE__);
+    }
+    return ret;
+}
+
+int check_cert_ocsp(SSL *ssl) {
+    int is_cert_valid = 1;
+    X509 *issuer_cert;
+    // Load issuer and server cert
+    STACK_OF(X509)* cert_stack = SSL_get0_verified_chain(ssl);
+    int32_t list_num = sk_X509_num(cert_stack);
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP list_num[%d]", __LINE__, list_num);
+
+    // check OCSP support
+    if (0 >= list_num) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP no verified cert. list_num[%d]", __LINE__, list_num);
+        return 2;
+    } else {
+      for (int32_t index = 0; index < list_num - 1; ++index) {
+        issuer_cert = sk_X509_value(cert_stack, index);
+        if (1 != checkOCSPSupport(issuer_cert)) {
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP index[%d]", __LINE__, index);
+          return 2;
+        }
+      }
+    }
+
+    X509 *ca_cert  = sk_X509_value(cert_stack, list_num - 1);      // root certification
+    X509 *subject_cert = sk_X509_value(cert_stack, 0);              // server certification
+    if (!ca_cert) {
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP root cert none in verified_chain", __LINE__);
+      return -1;
+    }
+    if (!subject_cert) {
+      X509_free(ca_cert);
+      (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP subject_cert none in verified_chain", __LINE__);
+      return -1;
+    }
+
+    // interm certs in chain cert check 
+    for (int32_t index = 1; index < list_num - 1; ++index) {
+        issuer_cert = sk_X509_value(cert_stack, index);
+        if (verify_ocsp_start(subject_cert, issuer_cert, cert_stack, ca_cert) != 1) {
+          (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP not verifyed. index[%d]", __LINE__, index);
+          is_cert_valid = -1;
+          break;
+        }
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d]OCSP verify OK. index[%d]", __LINE__, index);
+        subject_cert = issuer_cert;
+    }
+
+    // root cert check
+    if (is_cert_valid == 1) {
+      if (verify_ocsp_start(subject_cert, ca_cert, NULL, ca_cert) != 1) {
+        (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP root cert verify NG. ", __LINE__);
+        is_cert_valid = -1;
+      }
+    }
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP is_cert_valid[%d]", __LINE__, is_cert_valid);
+    return is_cert_valid;
+}
 /* TODO: Do more than just log the received stapled OCSP response. */
 static int tls_ocsp_response_cb(SSL *ssl, void *user_data) {
   BIO *bio = NULL;
@@ -2192,6 +3499,7 @@ static int tls_ocsp_response_cb(SSL *ssl
   BIO_puts(bio, "OCSP response: ");
   if (ptr == NULL) {
     BIO_puts(bio, "no response sent\n");
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "[tls.info][%d] OCSP response null.", __LINE__);
 
   } else {
     OCSP_RESPONSE *resp;
@@ -2231,6 +3539,7 @@ struct proxy_tls_next_proto {
 };
 
 #if defined(PR_USE_OPENSSL_NPN)
+/*
 static int tls_npn_cb(SSL *ssl,
     unsigned char **npn_out, unsigned char *npn_outlen,
     const unsigned char *npn_in, unsigned int npn_inlen,
@@ -2263,6 +3572,7 @@ static int tls_npn_cb(SSL *ssl,
 
   return SSL_TLSEXT_ERR_OK;
 }
+*/
 #endif /* PR_USE_OPENSSL_NPN */
 
 static int set_next_protocol(SSL_CTX *ctx) {
@@ -2286,12 +3596,12 @@ static int set_next_protocol(SSL_CTX *ct
   next_proto->encoded_protolen = encoded_protolen;
 
 # if defined(PR_USE_OPENSSL_NPN)
-  SSL_CTX_set_next_proto_select_cb(ctx, tls_npn_cb, next_proto);
+  // SSL_CTX_set_next_proto_select_cb(ctx, tls_npn_cb, next_proto);
 # endif /* NPN */
 
 # if defined(PR_USE_OPENSSL_ALPN)
-  SSL_CTX_set_alpn_protos(ctx, next_proto->encoded_proto,
-    next_proto->encoded_protolen);
+  // SSL_CTX_set_alpn_protos(ctx, next_proto->encoded_proto,
+  //   next_proto->encoded_protolen);
 # endif /* ALPN */
 
   return 0;
@@ -3099,6 +4409,10 @@ static struct tls_label tls_ciphersuite_
   { 0xC030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" },
   { 0xC031, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256" },
   { 0xC032, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384" },
+  { 0xC072, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" },
+  { 0xC073, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" },
+  { 0xC076, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
+  { 0xC077, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384" },
   { 0xC07A, "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256" },
   { 0xC07B, "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384" },
   { 0xC086, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256" },
@@ -3107,10 +4421,14 @@ static struct tls_label tls_ciphersuite_
   { 0xC08B, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384" },
   { 0xC09C, "TLS_RSA_WITH_AES_128_CCM" },
   { 0xC09D, "TLS_RSA_WITH_AES_256_CCM" },
+  { 0xC09E, "TLS_DHE_RSA_WITH_AES_128_CCM" },
+  { 0xC09F, "TLS_DHE_RSA_WITH_AES_256_CCM" },
+  { 0xC0A2, "TLS_DHE_RSA_WITH_AES_128_CCM_8" },
+  { 0xC0A3, "TLS_DHE_RSA_WITH_AES_256_CCM_8" },
   { 0xC0AC, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM" },
   { 0xC0AD, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM" },
-  { 0xC0AE, "TLS_DHE_RSA_WITH_AES_128_CCM" },
-  { 0xC0AF, "TLS_DHE_RSA_WITH_AES_256_CCM" },
+  { 0xC0AE, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 " },
+  { 0xC0AF, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 " },
   { 0xCCA8, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" },
   { 0xCCA9, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" },
   { 0xCCAA, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" },
@@ -4736,7 +6054,7 @@ int proxy_tls_sess_init(pool *p, struct
 # endif /* PSK support */
 
 # if !defined(OPENSSL_NO_TLSEXT) && defined(TLSEXT_STATUSTYPE_ocsp)
-  SSL_CTX_set_tlsext_status_cb(ssl_ctx, tls_ocsp_response_cb);
+  // SSL_CTX_set_tlsext_status_cb(ssl_ctx, tls_ocsp_response_cb);
 # endif /* OCSP support */
 
   if (tls_opts & PROXY_TLS_OPT_ALLOW_WEAK_SECURITY) {
diff -uprN proftpd_org/contrib/mod_proxy/mod_proxy.c proftpd/contrib/mod_proxy/mod_proxy.c
--- proftpd_org/contrib/mod_proxy/mod_proxy.c	2025-11-12 11:44:57.382270624 +0900
+++ proftpd/contrib/mod_proxy/mod_proxy.c	2025-11-12 11:17:39.075932722 +0900
@@ -25,7 +25,7 @@
  * $Archive: mod_proxy.a $
  * $Libraries: -lsqlite3 -lssl -lcrypto$
  */
-
+#include <ifaddrs.h>
 #include "mod_proxy.h"
 #include "proxy/random.h"
 #include "proxy/db.h"
@@ -2455,7 +2455,15 @@ static int proxy_data_prepare_backend_co
     /* Specify the specific address/interface to use as the source address for
      * connections to the destination server.
      */
-    bind_addr = proxy_sess->src_addr;
+    char ipstr[128];
+    if (pr_netaddr_get_family(proxy_sess->backend_data_addr) == AF_INET) {
+      get_ipv4_addr(cmd->pool, "eth0", ipstr, 128);
+      bind_addr = pr_netaddr_get_addr(cmd->pool, ipstr, NULL);
+    } else {
+      get_ipv6_addr(cmd->pool, "eth0", ipstr, 128);
+      bind_addr = pr_netaddr_get_addr(cmd->pool, ipstr, NULL);
+     }
+    (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,"[%d][%s]bind_addr[%s]", __LINE__, __func__, pr_netaddr_get_ipstr(bind_addr));
 
     /* Check the family of the remote address vs what we'll be using to connect.
      * If there's a mismatch, we need to get an addr with the matching family.
@@ -4379,7 +4387,7 @@ MODRET proxy_user(cmd_rec *cmd, struct p
           strerror(xerrno));
 
       } else {
-        pr_response_add_err(R_530, _("Login incorrect."));
+        pr_response_add_err(R_530, _("Proxy server connection error"));
       }
       break;
   }
