@@ -841,6 +841,39 @@ static int lcurl_info_get_slist_(lua_State *L, int opt){
841
841
return 1 ;
842
842
}
843
843
844
+ static int lcurl_info_get_certinfo_ (lua_State * L , int opt ){
845
+ lcurl_easy_t * p = lcurl_geteasy (L );
846
+ int decode = lua_toboolean (L , 2 );
847
+ struct curl_certinfo * val ; CURLcode code ;
848
+
849
+ code = curl_easy_getinfo (p -> curl , opt , & val );
850
+ if (code != CURLE_OK ){
851
+ return lcurl_fail_ex (L , p -> err_mode , LCURL_ERROR_EASY , code );
852
+ }
853
+
854
+ lua_newtable (L );
855
+ { int i = 0 ; for (;i < val -> num_of_certs ; ++ i ){
856
+ struct curl_slist * slist = val -> certinfo [i ];
857
+ if (decode ) {
858
+ lua_newtable (L );
859
+ for (;slist ; slist = slist -> next ){
860
+ const char * ptr = strchr (slist -> data , ':' );
861
+ if (ptr ){
862
+ lua_pushlstring (L , slist -> data , ptr - slist -> data );
863
+ lua_pushstring (L , ptr + 1 );
864
+ lua_rawset (L , -3 );
865
+ }
866
+ }
867
+ }
868
+ else {
869
+ lcurl_util_slist_to_table (L , slist );
870
+ }
871
+ lua_rawseti (L , -2 , i + 1 );
872
+ }}
873
+
874
+ return 1 ;
875
+ }
876
+
844
877
#define LCURL_STR_INFO (N , S ) static int lcurl_easy_get_##N(lua_State *L){\
845
878
return lcurl_info_get_string_(L, CURLINFO_##N); \
846
879
}
@@ -857,6 +890,10 @@ static int lcurl_info_get_slist_(lua_State *L, int opt){
857
890
return lcurl_info_get_double_(L, CURLINFO_##N);\
858
891
}
859
892
893
+ #define LCURL_CERTINFO_INFO (N , S ) static int lcurl_easy_get_##N(lua_State *L){\
894
+ return lcurl_info_get_certinfo_(L, CURLINFO_##N);\
895
+ }
896
+
860
897
#define OPT_ENTRY (L , N , T , S ) LCURL_##T##_INFO(N, S)
861
898
862
899
#include "lcinfoeasy.h"
0 commit comments