125 #define COOKIE_SECRET_LENGTH 16
200 if (cert_file != NULL)
214 if (key_file == NULL) key_file=cert_file;
282 int argi,
long argl,
long ret)
287 if (out == NULL)
return(ret);
291 BIO_printf(out,
"read from %p [%p] (%lu bytes => %ld (0x%lX))\n",
292 (
void *)bio,argp,(
unsigned long)argi,ret,ret);
298 BIO_printf(out,
"write to %p [%p] (%lu bytes => %ld (0x%lX))\n",
299 (
void *)bio,argp,(
unsigned long)argi,ret,ret);
314 else str=
"undefined";
345 const char *str_write_p, *str_version, *str_content_type =
"", *str_details1 =
"", *str_details2=
"";
347 str_write_p = write_p ?
">>>" :
"<<<";
352 str_version =
"SSL 2.0";
355 str_version =
"SSL 3.0 ";
358 str_version =
"TLS 1.0 ";
361 str_version =
"TLS 1.1 ";
364 str_version =
"TLS 1.2 ";
367 str_version =
"DTLS 1.0 ";
370 str_version =
"DTLS 1.0 (bad) ";
378 str_details1 =
"???";
382 switch (((
const unsigned char*)buf)[0])
385 str_details1 =
", ERROR:";
386 str_details2 =
" ???";
389 unsigned err = (((
const unsigned char*)buf)[1]<<8) + ((
const unsigned char*)buf)[2];
394 str_details2 =
" NO-CIPHER-ERROR";
397 str_details2 =
" NO-CERTIFICATE-ERROR";
400 str_details2 =
" BAD-CERTIFICATE-ERROR";
403 str_details2 =
" UNSUPPORTED-CERTIFICATE-TYPE-ERROR";
410 str_details1 =
", CLIENT-HELLO";
413 str_details1 =
", CLIENT-MASTER-KEY";
416 str_details1 =
", CLIENT-FINISHED";
419 str_details1 =
", SERVER-HELLO";
422 str_details1 =
", SERVER-VERIFY";
425 str_details1 =
", SERVER-FINISHED";
428 str_details1 =
", REQUEST-CERTIFICATE";
431 str_details1 =
", CLIENT-CERTIFICATE";
442 switch (content_type)
445 str_content_type =
"ChangeCipherSpec";
448 str_content_type =
"Alert";
451 str_content_type =
"Handshake";
455 if (content_type == 21)
457 str_details1 =
", ???";
461 switch (((
const unsigned char*)buf)[0])
464 str_details1 =
", warning";
467 str_details1 =
", fatal";
471 str_details2 =
" ???";
472 switch (((
const unsigned char*)buf)[1])
475 str_details2 =
" close_notify";
478 str_details2 =
" unexpected_message";
481 str_details2 =
" bad_record_mac";
484 str_details2 =
" decryption_failed";
487 str_details2 =
" record_overflow";
490 str_details2 =
" decompression_failure";
493 str_details2 =
" handshake_failure";
496 str_details2 =
" bad_certificate";
499 str_details2 =
" unsupported_certificate";
502 str_details2 =
" certificate_revoked";
505 str_details2 =
" certificate_expired";
508 str_details2 =
" certificate_unknown";
511 str_details2 =
" illegal_parameter";
514 str_details2 =
" unknown_ca";
517 str_details2 =
" access_denied";
520 str_details2 =
" decode_error";
523 str_details2 =
" decrypt_error";
526 str_details2 =
" export_restriction";
529 str_details2 =
" protocol_version";
532 str_details2 =
" insufficient_security";
535 str_details2 =
" internal_error";
538 str_details2 =
" user_canceled";
541 str_details2 =
" no_renegotiation";
544 str_details2 =
" unsupported_extension";
547 str_details2 =
" certificate_unobtainable";
550 str_details2 =
" unrecognized_name";
553 str_details2 =
" bad_certificate_status_response";
556 str_details2 =
" bad_certificate_hash_value";
559 str_details2 =
" unknown_psk_identity";
565 if (content_type == 22)
567 str_details1 =
"???";
571 switch (((
const unsigned char*)buf)[0])
574 str_details1 =
", HelloRequest";
577 str_details1 =
", ClientHello";
580 str_details1 =
", ServerHello";
583 str_details1 =
", HelloVerifyRequest";
586 str_details1 =
", Certificate";
589 str_details1 =
", ServerKeyExchange";
592 str_details1 =
", CertificateRequest";
595 str_details1 =
", ServerHelloDone";
598 str_details1 =
", CertificateVerify";
601 str_details1 =
", ClientKeyExchange";
604 str_details1 =
", Finished";
610 #ifndef OPENSSL_NO_HEARTBEATS
611 if (content_type == 24)
613 str_details1 =
", Heartbeat";
617 switch (((
const unsigned char*)buf)[0])
620 str_details1 =
", HeartbeatRequest";
623 str_details1 =
", HeartbeatResponse";
631 BIO_printf(bio,
"%s %s%s [length %04lx]%s%s\n", str_write_p, str_version, str_content_type, (
unsigned long)len, str_details1, str_details2);
643 for (i = 0; i <
num; i++)
645 if (i % 16 == 0 && i > 0)
647 BIO_printf(bio,
" %02x", ((
const unsigned char*)buf)[i]);
666 extname =
"server name";
670 extname =
"max fragment length";
674 extname =
"client certificate URL";
678 extname =
"trusted CA keys";
682 extname =
"truncated HMAC";
686 extname =
"status request";
690 extname =
"user mapping";
694 extname =
"client authz";
698 extname =
"server authz";
702 extname =
"cert type";
706 extname =
"elliptic curves";
710 extname =
"EC point formats";
718 extname =
"signature algorithms";
722 extname =
"use SRTP";
726 extname =
"heartbeat";
730 extname =
"session ticket";
734 extname =
"renegotiation info";
737 #ifdef TLSEXT_TYPE_opaque_prf_input
738 case TLSEXT_TYPE_opaque_prf_input:
739 extname =
"opaque PRF input";
742 #ifdef TLSEXT_TYPE_next_proto_neg
744 extname =
"next protocol";
754 BIO_printf(bio,
"TLS %s extension \"%s\" (id=%d), len=%d\n",
755 client_server ?
"server":
"client",
764 unsigned int length, resultlength;
767 struct sockaddr_in s4;
769 struct sockaddr_in6 s6;
789 switch (peer.sa.sa_family)
792 length +=
sizeof(
struct in_addr);
793 length +=
sizeof(peer.s4.sin_port);
797 length +=
sizeof(
struct in6_addr);
798 length +=
sizeof(peer.s6.sin6_port);
813 switch (peer.sa.sa_family)
818 sizeof(peer.s4.sin_port));
819 memcpy(buffer +
sizeof(peer.s4.sin_port),
821 sizeof(
struct in_addr));
827 sizeof(peer.s6.sin6_port));
828 memcpy(buffer +
sizeof(peer.s6.sin6_port),
830 sizeof(
struct in6_addr));
840 buffer, length, result, &resultlength);
843 memcpy(cookie, result, resultlength);
844 *cookie_len = resultlength;
852 unsigned int length, resultlength;
855 struct sockaddr_in s4;
857 struct sockaddr_in6 s6;
870 switch (peer.sa.sa_family)
873 length +=
sizeof(
struct in_addr);
874 length +=
sizeof(peer.s4.sin_port);
878 length +=
sizeof(
struct in6_addr);
879 length +=
sizeof(peer.s6.sin6_port);
894 switch (peer.sa.sa_family)
899 sizeof(peer.s4.sin_port));
900 memcpy(buffer +
sizeof(peer.s4.sin_port),
902 sizeof(
struct in_addr));
908 sizeof(peer.s6.sin6_port));
909 memcpy(buffer +
sizeof(peer.s6.sin6_port),
911 sizeof(
struct in6_addr));
921 buffer, length, result, &resultlength);
924 if (cookie_len == resultlength && memcmp(result, cookie, resultlength) == 0)