︙ | | |
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
-
+
-
+
-
+
-
+
-
+
-
+
|
if (objc > 2 && Tcl_GetBooleanFromObj( interp, objv[2],
&verbose) != TCL_OK) {
return TCL_ERROR;
}
switch ((enum protocol)index) {
case TLS_SSL2:
#if defined(NO_SSL2)
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return TCL_ERROR;
#else
ctx = SSL_CTX_new(SSLv2_method()); break;
#endif
case TLS_SSL3:
#if defined(NO_SSL3)
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return TCL_ERROR;
#else
ctx = SSL_CTX_new(SSLv3_method()); break;
#endif
case TLS_TLS1:
#if defined(NO_TLS1)
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return TCL_ERROR;
#else
ctx = SSL_CTX_new(TLSv1_method()); break;
#endif
case TLS_TLS1_1:
#if defined(NO_TLS1_1)
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return TCL_ERROR;
#else
ctx = SSL_CTX_new(TLSv1_1_method()); break;
#endif
case TLS_TLS1_2:
#if defined(NO_TLS1_2)
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return TCL_ERROR;
#else
ctx = SSL_CTX_new(TLSv1_2_method()); break;
#endif
case TLS_TLS1_3:
#if defined(NO_TLS1_3)
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return TCL_ERROR;
#else
ctx = SSL_CTX_new(TLS_method()); break;
SSL_CTX_set_min_proto_version (ctx, TLS1_3_VERSION);
SSL_CTX_set_max_proto_version (ctx, TLS1_3_VERSION);
#endif
default:
|
︙ | | |
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
-
+
|
}
/*
* Make sure to operate on the topmost channel
*/
chan = Tcl_GetTopChannel(chan);
if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan), "\": not a TLS channel", NULL);
Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan), "\": not a TLS channel", (char *)NULL);
return(TCL_ERROR);
}
statePtr = (State *)Tcl_GetChannelInstanceData(chan);
dprintf("Calling Tls_WaitForConnect");
ret = Tls_WaitForConnect(statePtr, &err, 1);
dprintf("Tls_WaitForConnect returned: %i", ret);
|
︙ | | |
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
|
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
|
-
+
|
/*
* Make sure to operate on the topmost channel
*/
chan = Tcl_GetTopChannel(chan);
if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
Tcl_AppendResult(interp, "bad channel \"",
Tcl_GetChannelName(chan), "\": not a TLS channel", NULL);
Tcl_GetChannelName(chan), "\": not a TLS channel", (char *)NULL);
Tls_Free((void *)statePtr);
return TCL_ERROR;
}
ctx = ((State *)Tcl_GetChannelInstanceData(chan))->ctx;
} else {
if ((ctx = CTX_Init(statePtr, server, proto, keyfile, certfile, key,
cert, key_len, cert_len, CAdir, CAfile, ciphers,
|
︙ | | |
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
|
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
|
-
+
|
/*
* Make sure to operate on the topmost channel
*/
chan = Tcl_GetTopChannel(chan);
if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan),
"\": not a TLS channel", NULL);
"\": not a TLS channel", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_UnstackChannel(interp, chan) == TCL_ERROR) {
return TCL_ERROR;
}
|
︙ | | |
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
|
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
int off = 0;
int load_private_key;
const SSL_METHOD *method;
dprintf("Called");
if (!proto) {
Tcl_AppendResult(interp, "no valid protocol selected", NULL);
Tcl_AppendResult(interp, "no valid protocol selected", (char *)NULL);
return (SSL_CTX *)0;
}
/* create SSL context */
#if defined(NO_SSL2)
if (ENABLED(proto, TLS_PROTO_SSL2)) {
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return (SSL_CTX *)0;
}
#endif
#if defined(NO_SSL3)
if (ENABLED(proto, TLS_PROTO_SSL3)) {
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return (SSL_CTX *)0;
}
#endif
#if defined(NO_TLS1)
if (ENABLED(proto, TLS_PROTO_TLS1)) {
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return (SSL_CTX *)0;
}
#endif
#if defined(NO_TLS1_1)
if (ENABLED(proto, TLS_PROTO_TLS1_1)) {
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return (SSL_CTX *)0;
}
#endif
#if defined(NO_TLS1_2)
if (ENABLED(proto, TLS_PROTO_TLS1_2)) {
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return (SSL_CTX *)0;
}
#endif
#if defined(NO_TLS1_3)
if (ENABLED(proto, TLS_PROTO_TLS1_3)) {
Tcl_AppendResult(interp, "protocol not supported", NULL);
Tcl_AppendResult(interp, "protocol not supported", (char *)NULL);
return (SSL_CTX *)0;
}
#endif
switch (proto) {
#if !defined(NO_SSL2)
case TLS_PROTO_SSL2:
|
︙ | | |
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
|
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
|
-
+
|
}
/*
* Make sure to operate on the topmost channel
*/
chan = Tcl_GetTopChannel(chan);
if (Tcl_GetChannelType(chan) != Tls_ChannelType()) {
Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan),
"\": not a TLS channel", NULL);
"\": not a TLS channel", (char *)NULL);
return TCL_ERROR;
}
statePtr = (State *) Tcl_GetChannelInstanceData(chan);
if (objc == 2) {
peer = SSL_get_peer_certificate(statePtr->ssl);
} else {
peer = SSL_get_certificate(statePtr->ssl);
|
︙ | | |
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
|
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
|
-
+
|
Tcl_PkgRequire(interp, "Tcl", "8.6-", 0)
#endif
== NULL) {
return TCL_ERROR;
}
if (TlsLibInit(0) != TCL_OK) {
Tcl_AppendResult(interp, "could not initialize SSL library", NULL);
Tcl_AppendResult(interp, "could not initialize SSL library", (char *)NULL);
return TCL_ERROR;
}
Tcl_CreateObjCommand(interp, "tls::ciphers", CiphersObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand(interp, "tls::handshake", HandshakeObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand(interp, "tls::import", ImportObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand(interp, "tls::unimport", UnimportObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
|
︙ | | |