8 #include <openssl/opensslv.h>
9 #include <openssl/x509v3.h>
10 #include <openssl/x509_vfy.h>
11 #include <openssl/crypto.h>
12 #include <openssl/lhash.h>
13 #include <openssl/objects.h>
14 #include <openssl/err.h>
15 #include <openssl/evp.h>
16 #include <openssl/x509.h>
17 #include <openssl/pkcs12.h>
18 #include <openssl/bio.h>
19 #include <openssl/ssl.h>
25 unsigned char * accessinfoURL ;
30 static unsigned char *i2s_ASN1_IA5STRING( ASN1_IA5STRING *ia5)
33 if(!ia5 || !ia5->length)
return NULL;
34 tmp = OPENSSL_malloc(ia5->length + 1);
35 memcpy(tmp, ia5->data, ia5->length);
42 static unsigned char *my_get_ext(X509 * cert,
const int type,
46 STACK_OF(ACCESS_DESCRIPTION) * accessinfo ;
47 accessinfo = X509_get_ext_d2i(cert, extensiontype,
NULL,
NULL) ;
49 if (!sk_ACCESS_DESCRIPTION_num(accessinfo))
52 for (i = 0; i < sk_ACCESS_DESCRIPTION_num(accessinfo); i++) {
53 ACCESS_DESCRIPTION * ad = sk_ACCESS_DESCRIPTION_value(accessinfo, i);
54 if (OBJ_obj2nid(ad->method) == type) {
55 if (ad->location->type == GEN_URI) {
56 return i2s_ASN1_IA5STRING(ad->location->d.ia5);
64 void * globalparm =
NULL;
66 static int ssl_app_verify_callback(X509_STORE_CTX *ctx,
void *arg)
71 fprintf(stderr,
"ssl_app_verify_callback sslctxparm=%p ctx=%p\n",
72 (
void *)p, (
void*)ctx);
74 #if OPENSSL_VERSION_NUMBER<0x00907000L
77 fprintf(stderr,
"This version %s of openssl does not support a parm (%p)"
78 ", getting a global static %p \n",
79 OPENSSL_VERSION_TEXT, (
void *)p, (
void *)globalparm);
86 fprintf(stderr,
"Internal error in ssl_app_verify_callback "
87 "sslctxparm=%p ctx=%p\n",(
void *)p,(
void*)ctx);
91 ok= X509_verify_cert(ctx);
92 err=X509_STORE_CTX_get_error(ctx);
97 if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT ||
98 err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) {
99 fprintf(stderr,
"X509_verify_cert: repairing self signed\n") ;
100 X509_STORE_CTX_set_error(ctx,X509_V_OK);
105 if (ok && ctx->cert) {
106 unsigned char * accessinfoURL ;
108 accessinfoURL = my_get_ext(ctx->cert,p->accesstype ,NID_info_access);
111 if (
strcmp((
char *)p->accessinfoURL, (
char *)accessinfoURL)) {
112 fprintf(stderr,
"Setting URL <%s>, was <%s>\n",
113 accessinfoURL,p->accessinfoURL);
114 OPENSSL_free(p->accessinfoURL);
115 p->accessinfoURL = accessinfoURL;
119 OPENSSL_free(accessinfoURL);
126 static CURLcode sslctxfun(
CURL * curl,
void * sslctx,
void * parm)
130 SSL_CTX * ctx = (SSL_CTX *) sslctx ;
131 fprintf(stderr,
"sslctxfun start curl=%p ctx=%p parm=%p\n",
132 (
void *)curl,(
void *)ctx,(
void *)p);
134 SSL_CTX_set_quiet_shutdown(ctx,1);
135 SSL_CTX_set_cipher_list(ctx,
"RC4-MD5");
136 SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
141 SSL_CTX_set_verify_depth(ctx,0);
142 SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,
NULL);
144 #if OPENSSL_VERSION_NUMBER<0x00907000L
146 fprintf(stderr,
"This version %s of openssl does not support a parm,"
147 " setting global one\n", OPENSSL_VERSION_TEXT);
153 SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm);
154 fprintf(stderr,
"sslctxfun end\n");
171 p.accessinfoURL = (
unsigned char *)
strdup(URL);
172 p.accesstype = OBJ_obj2nid(OBJ_txt2obj(
"AD_DVCS",0)) ;
182 fprintf(stderr,
"Going to perform %s\n",p.accessinfoURL);
199 interval.tv_usec = 0;
203 fprintf(stderr,
"running=%d res=%d\n",running,res);
213 fprintf(stderr,
"not okay???\n");
223 fprintf(stderr,
"unexpected failured of fdset.\n");
227 if (
select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
228 fprintf(stderr,
"bad select??\n");
239 fprintf(stderr,
"all done\n");
246 free(p.accessinfoURL);
CURLcode curl_global_init(long flags)
Globally initializes cURL given a bitwise set of the different features to initialize.
CURLMcode curl_multi_fdset(CURLM *multi_handle, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *exc_fd_set, int *max_fd)
GLuint GLuint GLsizei GLenum type
CURLcode curl_easy_setopt(CURL *curl, CURLoption option,...)
void curl_global_cleanup(void)
Globally cleanup cURL, uses the value of "init_flags" to determine what needs to be cleaned up and ...
CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *curl_handle)
CURLM * curl_multi_init(void)
CURLMcode curl_multi_cleanup(CURLM *multi_handle)
static WindowRef ValidModeCallbackProc inCallback OSStatus err
CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *curl_handle)
void curl_easy_cleanup(CURL *curl)
CURL * curl_easy_init(void)
CURLMsg * curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue)
struct sslctxparm_st sslctxparm