229 |
|
return(1); |
230 |
|
} |
231 |
|
|
232 |
< |
long MS_CALLBACK bio_dump_cb(BIO *bio, int cmd, const char *argp, int argi, |
233 |
< |
long argl, long ret) |
232 |
> |
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key) |
233 |
|
{ |
234 |
+ |
if (cert == NULL) |
235 |
+ |
return 1; |
236 |
+ |
if (SSL_CTX_use_certificate(ctx,cert) <= 0) |
237 |
+ |
{ |
238 |
+ |
BIO_printf(bio_err,"error setting certificate\n"); |
239 |
+ |
ERR_print_errors(bio_err); |
240 |
+ |
return 0; |
241 |
+ |
} |
242 |
+ |
if (SSL_CTX_use_PrivateKey(ctx,key) <= 0) |
243 |
+ |
{ |
244 |
+ |
BIO_printf(bio_err,"error setting private key\n"); |
245 |
+ |
ERR_print_errors(bio_err); |
246 |
+ |
return 0; |
247 |
+ |
} |
248 |
+ |
|
249 |
+ |
|
250 |
+ |
/* Now we know that a key and cert have been set against |
251 |
+ |
* the SSL context */ |
252 |
+ |
if (!SSL_CTX_check_private_key(ctx)) |
253 |
+ |
{ |
254 |
+ |
BIO_printf(bio_err,"Private key does not match the certificate public key\n"); |
255 |
+ |
return 0; |
256 |
+ |
} |
257 |
+ |
return 1; |
258 |
+ |
} |
259 |
+ |
|
260 |
+ |
long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp, |
261 |
+ |
int argi, long argl, long ret) |
262 |
+ |
{ |
263 |
|
BIO *out; |
264 |
|
|
265 |
|
out=(BIO *)BIO_get_callback_arg(bio); |
267 |
|
|
268 |
|
if (cmd == (BIO_CB_READ|BIO_CB_RETURN)) |
269 |
|
{ |
270 |
< |
BIO_printf(out,"read from %08X [%08lX] (%d bytes => %ld (0x%X))\n", |
271 |
< |
bio,argp,argi,ret,ret); |
270 |
> |
BIO_printf(out,"read from %p [%p] (%d bytes => %ld (0x%lX))\n", |
271 |
> |
(void *)bio,argp,argi,ret,ret); |
272 |
|
BIO_dump(out,argp,(int)ret); |
273 |
|
return(ret); |
274 |
|
} |
275 |
|
else if (cmd == (BIO_CB_WRITE|BIO_CB_RETURN)) |
276 |
|
{ |
277 |
< |
BIO_printf(out,"write to %08X [%08lX] (%d bytes => %ld (0x%X))\n", |
278 |
< |
bio,argp,argi,ret,ret); |
277 |
> |
BIO_printf(out,"write to %p [%p] (%d bytes => %ld (0x%lX))\n", |
278 |
> |
(void *)bio,argp,argi,ret,ret); |
279 |
|
BIO_dump(out,argp,(int)ret); |
280 |
|
} |
281 |
|
return(ret); |
283 |
|
|
284 |
|
void MS_CALLBACK apps_ssl_info_callback(const SSL *s, int where, int ret) |
285 |
|
{ |
286 |
< |
char *str; |
286 |
> |
const char *str; |
287 |
|
int w; |
288 |
|
|
289 |
|
w=where& ~SSL_ST_MASK; |
346 |
|
|
347 |
|
if (len > 0) |
348 |
|
{ |
349 |
< |
switch (((unsigned char*)buf)[0]) |
349 |
> |
switch (((const unsigned char*)buf)[0]) |
350 |
|
{ |
351 |
|
case 0: |
352 |
|
str_details1 = ", ERROR:"; |
353 |
|
str_details2 = " ???"; |
354 |
|
if (len >= 3) |
355 |
|
{ |
356 |
< |
unsigned err = (((unsigned char*)buf)[1]<<8) + ((unsigned char*)buf)[2]; |
356 |
> |
unsigned err = (((const unsigned char*)buf)[1]<<8) + ((const unsigned char*)buf)[2]; |
357 |
|
|
358 |
|
switch (err) |
359 |
|
{ |
422 |
|
|
423 |
|
if (len == 2) |
424 |
|
{ |
425 |
< |
switch (((unsigned char*)buf)[0]) |
425 |
> |
switch (((const unsigned char*)buf)[0]) |
426 |
|
{ |
427 |
|
case 1: |
428 |
|
str_details1 = ", warning"; |
433 |
|
} |
434 |
|
|
435 |
|
str_details2 = " ???"; |
436 |
< |
switch (((unsigned char*)buf)[1]) |
436 |
> |
switch (((const unsigned char*)buf)[1]) |
437 |
|
{ |
438 |
|
case 0: |
439 |
|
str_details2 = " close_notify"; |
514 |
|
|
515 |
|
if (len > 0) |
516 |
|
{ |
517 |
< |
switch (((unsigned char*)buf)[0]) |
517 |
> |
switch (((const unsigned char*)buf)[0]) |
518 |
|
{ |
519 |
|
case 0: |
520 |
|
str_details1 = ", HelloRequest"; |
567 |
|
{ |
568 |
|
if (i % 16 == 0 && i > 0) |
569 |
|
BIO_printf(bio, "\n "); |
570 |
< |
BIO_printf(bio, " %02x", ((unsigned char*)buf)[i]); |
570 |
> |
BIO_printf(bio, " %02x", ((const unsigned char*)buf)[i]); |
571 |
|
} |
572 |
|
if (i < len) |
573 |
|
BIO_printf(bio, " ..."); |