浏览代码

components/openssl: 1. add stack_st structure and its advanced defination including its derived child defination
2. add SSL_add_client_CA & SSL_get_certificate

dongheng 9 年之前
父节点
当前提交
c504fe4856

+ 17 - 2
components/openssl/include/internal/ssl_types.h

@@ -20,7 +20,6 @@
 typedef void SSL_CIPHER;
 
 typedef void X509_STORE_CTX;
-typedef void X509_NAME;
 typedef void X509_STORE;
 
 typedef void RSA;
@@ -28,7 +27,19 @@ typedef void RSA;
 typedef void STACK;
 typedef void BIO;
 
-#define STACK_OF(x) x
+#define STACK_OF(type)  struct stack_st_##type
+
+#define SKM_DEFINE_STACK_OF(t1, t2, t3) \
+    STACK_OF(t1); \
+    static ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \
+    { \
+        return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \
+    } \
+
+#define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t)
+
+struct stack_st;
+typedef struct stack_st OPENSSL_STACK;
 
 struct ssl_method_st;
 typedef struct ssl_method_st SSL_METHOD;
@@ -66,6 +77,10 @@ typedef struct x509_method_st X509_METHOD;
 struct pkey_method_st;
 typedef struct pkey_method_st PKEY_METHOD;
 
+struct stack_st {
+    char *data;
+};
+
 struct evp_pkey_st {
 
     void *pkey_pm;

+ 2 - 0
components/openssl/include/internal/ssl_x509.h

@@ -17,6 +17,8 @@
 
 #include "ssl_types.h"
 
+DEFINE_STACK_OF(X509_NAME)
+
 X509* sk_X509_NAME_new_null(void);
 
 X509* d2i_X509(X509 **cert, const unsigned char *buffer, long len);

+ 27 - 0
components/openssl/library/ssl_x509.c

@@ -119,6 +119,21 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x)
     return 1;
 }
 
+/*
+ * SSL_add_client_CA - add CA client certification into the SSL
+ *
+ * @param ssl - SSL point
+ * @param x   - CA certification point
+ *
+ * @return
+ *        1 : OK
+ *        0 : failed
+ */
+int SSL_add_client_CA(SSL *ssl, X509 *x)
+{
+
+}
+
 /*
  * SSL_CTX_use_certificate - set the SSL context certification
  *
@@ -139,6 +154,18 @@ int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x)
     return 1;
 }
 
+/*
+ * SSL_get_certificate - get the SSL certification point
+ *
+ * @param ssl - SSL point
+ *
+ * @return SSL certification point
+ */
+X509 *SSL_get_certificate(const SSL *ssl)
+{
+    return ssl->cert->x509;
+}
+
 /*
  * SSL_CTX_use_certificate_ASN1 - load certification into the SSL context
  *