ADDED .fossil-settings/crlf-glob Index: .fossil-settings/crlf-glob ================================================================== --- /dev/null +++ .fossil-settings/crlf-glob @@ -0,0 +1,1 @@ +win/*.vc Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -15,14 +15,15 @@ config.log config.status configure manifest.uuid pkgIndex.tcl -tls.tcl.h -tls.tcl.h.new.1 -tls.tcl.h.new.2 -tlsUuid.h -win/versions.vc +*Uuid.h +win/Debug* win/Release* -win/Debug* +win/version*.vc +win/nmakehlp.exe +win/nmakehlp.obj +win/nmakehlp.out +win/_junk.pch win/nmhlp-out.txt *~ Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -158,11 +158,11 @@ # compiled with. #DEFS = $(TCL_DEFS) @DEFS@ $(PKG_CFLAGS) DEFS = @DEFS@ $(PKG_CFLAGS) # Move pkgIndex.tcl to 'BINARIES' var if it is generated in the Makefile -CONFIG_CLEAN_FILES = Makefile pkgIndex.tcl generic/tls.tcl.h tlsUuid.h +CONFIG_CLEAN_FILES = Makefile CLEANFILES = @CLEANFILES@ CPPFLAGS = @CPPFLAGS@ LIBS = @PKG_LIBS@ @LIBS@ AR = @AR@ @@ -214,11 +214,11 @@ @echo "If you have documentation to create, place the commands to" @echo "build the docs in the 'doc:' target. For example:" @echo " xml2nroff sample.xml > sample.n" @echo " xml2html sample.xml > sample.html" -install: all install-binaries install-libraries install-doc +install: all install-binaries install-libraries install-doc-n install-doc-html install-binaries: binaries install-lib-binaries install-bin-binaries #======================================================================== # This rule installs platform-independent files, such as header files. @@ -229,23 +229,34 @@ @$(INSTALL_DATA_DIR) "$(DESTDIR)$(includedir)" @echo "Installing header files in $(DESTDIR)$(includedir)" @list='$(PKG_HEADERS)'; for i in $$list; do \ echo "Installing $(srcdir)/$$i" ; \ $(INSTALL_DATA) $(srcdir)/$$i "$(DESTDIR)$(includedir)" ; \ - done; + done #======================================================================== # Install documentation. Unix manpages should go in the $(mandir) # directory. #======================================================================== + +install-doc-html: doc + @$(INSTALL_DATA_DIR) "$(DESTDIR)$(pkglibdir)/html" + @list='$(srcdir)/doc/*.html'; for i in $$list; do \ + if test -f $$i ; then \ + echo "Installing $$i"; \ + $(INSTALL_DATA) $$i "$(DESTDIR)$(pkglibdir)/html"; \ + fi; \ + done -install-doc: doc +install-doc-n: doc @$(INSTALL_DATA_DIR) "$(DESTDIR)$(mandir)/mann" @echo "Installing documentation in $(DESTDIR)$(mandir)" @list='$(srcdir)/doc/*.n'; for i in $$list; do \ - echo "Installing $$i"; \ - $(INSTALL_DATA) $$i "$(DESTDIR)$(mandir)/mann" ; \ + if test -f $$i ; then \ + echo "Installing $$i"; \ + $(INSTALL_DATA) $$i "$(DESTDIR)$(mandir)/mann" ; \ + fi; \ done test: binaries libraries $(TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS) \ -load "package ifneeded $(PACKAGE_NAME) $(PACKAGE_VERSION) \ @@ -308,24 +319,19 @@ # As necessary, add $(srcdir):$(srcdir)/compat:.... #======================================================================== VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win:$(srcdir)/macosx -.c.@OBJEXT@: - $(COMPILE) -c `@CYGPATH@ $<` -o $@ - # Create a C-source-ified version of the script resources # for TclTLS so that we only need a single file to enable # this extension tls.tcl.h: @srcdir@/library/tls.tcl Makefile od -A n -v -t xC < '@srcdir@/library/tls.tcl' > tls.tcl.h.new.1 sed 's@[^0-9A-Fa-f]@@g;s@..@0x&, @g' < tls.tcl.h.new.1 > tls.tcl.h.new.2 rm -f tls.tcl.h.new.1 mv tls.tcl.h.new.2 @srcdir@/generic/tls.tcl.h -tls.o: tlsUuid.h - $(srcdir)/manifest.uuid: printf "git-" >$(srcdir)/manifest.uuid (cd $(srcdir); git rev-parse HEAD >>$(srcdir)/manifest.uuid || \ (printf "svn-r" >$(srcdir)/manifest.uuid ; \ svn info --show-item last-changed-revision >>$(srcdir)/manifest.uuid) || \ @@ -334,10 +340,15 @@ tlsUuid.h: $(srcdir)/manifest.uuid echo "#define TLS_VERSION_UUID \\" >$@ cat $(srcdir)/manifest.uuid >>$@ echo "" >>$@ +tls.@OBJEXT@: tlsUuid.h tls.tcl.h + +.c.@OBJEXT@: + $(COMPILE) -c `@CYGPATH@ $<` -o $@ + #======================================================================== # Create the pkgIndex.tcl file. # It is usually easiest to let Tcl do this for you with pkg_mkIndex, but # you may find that you need to customize the package. If so, either # modify the -hand version, or create a pkgIndex.tcl.in file and have @@ -361,13 +372,13 @@ DIST_INSTALL_DATA = CPPROG='cp -p' $(INSTALL) -m 644 DIST_INSTALL_DATA_RECUR = CPPROG='cp -p -R' $(INSTALL) DIST_INSTALL_SCRIPT = CPPROG='cp -p' $(INSTALL) -m 755 dist-clean: - rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR).tar.* + rm -rf $(DIST_DIR) $(top_builddir)/$(PKG_DIR).tar.* -dist: dist-clean +dist: dist-clean $(srcdir)/manifest.uuid # TEA files $(INSTALL_DATA_DIR) $(DIST_DIR) $(DIST_INSTALL_DATA) $(srcdir)/Makefile.in \ $(srcdir)/acinclude.m4 $(srcdir)/aclocal.m4 \ $(srcdir)/configure.ac $(DIST_DIR)/ @@ -376,32 +387,21 @@ # Extension files $(DIST_INSTALL_DATA) $(srcdir)/ChangeLog \ $(srcdir)/license.terms $(srcdir)/manifest.uuid \ $(srcdir)/README.txt $(srcdir)/pkgIndex.tcl.in $(DIST_DIR)/ - # TEA files - $(INSTALL_DATA_DIR) $(DIST_DIR)/tclconfig - $(DIST_INSTALL_DATA) $(srcdir)/tclconfig/README.txt \ - $(srcdir)/tclconfig/tcl.m4 $(srcdir)/tclconfig/install-sh \ - $(srcdir)/tclconfig/license.terms $(DIST_DIR)/tclconfig/ - - $(INSTALL_DATA_DIR) $(DIST_DIR)/win - $(DIST_INSTALL_DATA) \ - $(srcdir)/win/README.txt $(srcdir)/win/*.vc \ - $(srcdir)/win/nmakehlp.c $(srcdir)/win/*.in $(DIST_DIR)/win/ - - list='build demos doc generic library macosx tests unix'; \ + list='build demos doc generic library tclconfig tests win'; \ for p in $$list; do \ if test -d $(srcdir)/$$p ; then \ $(INSTALL_DATA_DIR) $(DIST_DIR)/$$p; \ $(DIST_INSTALL_DATA_RECUR) $(srcdir)/$$p/* $(DIST_DIR)/$$p/; \ fi; \ done (cd $(DIST_ROOT); $(COMPRESS);) - cd $(top_builddir) mv $(DIST_ROOT)/$(PKG_DIR).tar.gz $(top_builddir) + cd $(top_builddir) #======================================================================== # End of user-definable section #======================================================================== @@ -416,11 +416,11 @@ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean: clean -rm -f *.tab.c -rm -f $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log config.status + -rm -f config.cache config.log config.status configure~ -rm -fR autom4te.cache #======================================================================== # Install binary object libraries. On Windows this includes both .dll and # .lib files. Because the .lib files are not explicitly listed anywhere, @@ -457,10 +457,13 @@ done @if test "x$(SHARED_BUILD)" = "x1"; then \ echo " Install pkgIndex.tcl $(DESTDIR)$(pkglibdir)"; \ $(INSTALL_DATA) pkgIndex.tcl "$(DESTDIR)$(pkglibdir)"; \ fi + @if test -f "$(srcdir)/tlsConfig.sh"; then \ + $(INSTALL_DATA) $(srcdir)/tlsConfig.sh $(DESTDIR)$(libdir); \ + fi #======================================================================== # Install binary executables (e.g. .exe files and dependent .dll files) # This is for files that must go in the bin directory (located next to # wish and tclsh), like dependent .dll files on Windows. Index: acinclude.m4 ================================================================== --- acinclude.m4 +++ acinclude.m4 @@ -7,42 +7,43 @@ # # Add here whatever m4 macros you want to define for your package # AC_DEFUN([TCLTLS_SSL_OPENSSL], [ + dnl Determine if pkg-config tool is available AC_CHECK_TOOL([PKG_CONFIG], [pkg-config]) dnl Disable support for TLS 1.0 protocol AC_ARG_ENABLE([tls1], AS_HELP_STRING([--disable-tls1], [disable TLS1 protocol]), [ - if test "${enableval}" = "no"; then + if test "${enableval}" == "no"; then AC_DEFINE([NO_TLS1], [1], [Disable TLS1 protocol]) AC_MSG_CHECKING([for disable TLS1 protocol]) AC_MSG_RESULT([yes]) fi ]) dnl Disable support for TLS 1.1 protocol AC_ARG_ENABLE([tls1_1], AS_HELP_STRING([--disable-tls1_1], [disable TLS1.1 protocol]), [ - if test "${enableval}" = "no"; then + if test "${enableval}" == "no"; then AC_DEFINE([NO_TLS1_1], [1], [Disable TLS1.1 protocol]) AC_MSG_CHECKING([for disable TLS1.1 protocol]) AC_MSG_RESULT([yes]) fi ]) dnl Disable support for TLS 1.2 protocol AC_ARG_ENABLE([tls1_2], AS_HELP_STRING([--disable-tls1_2], [disable TLS1.2 protocol]), [ - if test "${enableval}" = "no"; then + if test "${enableval}" == "no"; then AC_DEFINE([NO_TLS1_2], [1], [Disable TLS1.2 protocol]) AC_MSG_CHECKING([for disable TLS1.2 protocol]) AC_MSG_RESULT([yes]) fi ]) dnl Disable support for TLS 1.3 protocol AC_ARG_ENABLE([tls1_3], AS_HELP_STRING([--disable-tls1_3], [disable TLS1.3 protocol]), [ - if test "${enableval}" = "no"; then + if test "${enableval}" == "no"; then AC_DEFINE([NO_TLS1_3], [1], [Disable TLS1.3 protocol]) AC_MSG_CHECKING([for disable TLS1.3 protocol]) AC_MSG_RESULT([yes]) fi ]) @@ -53,11 +54,11 @@ [enable using the underlying file descriptor for talking directly to the SSL library]), [ tcltls_ssl_fastpath="$enableval" ], [ tcltls_ssl_fastpath='no' ]) - if test "$tcltls_ssl_fastpath" = 'yes'; then + if test "$tcltls_ssl_fastpath" == 'yes'; then AC_DEFINE(TCLTLS_SSL_USE_FASTPATH, [1], [Enable SSL library direct use of the underlying file descriptor]) fi AC_MSG_CHECKING([for fast path]) AC_MSG_RESULT([$tcltls_ssl_fastpath]) @@ -66,12 +67,12 @@ AC_ARG_ENABLE([hardening], AS_HELP_STRING([--enable-hardening], [enable hardening attempts]), [ tcltls_enable_hardening="$enableval" ], [ tcltls_enable_hardening='yes' ]) - if test "$tcltls_enable_hardening" = 'yes'; then - if test "$GCC" = 'yes' -o "$CC" = 'clang'; then + if test "$tcltls_enable_hardening" == 'yes'; then + if test "$GCC" == 'yes' -o "$CC" = 'clang'; then TEA_ADD_CFLAGS([-fstack-protector-all]) TEA_ADD_CFLAGS([-fno-strict-overflow]) AC_DEFINE([_FORTIFY_SOURCE], [2], [Enable fortification]) fi fi @@ -107,29 +108,28 @@ AS_HELP_STRING([--with-openssl-includedir=
tls - binding to OpenSSL library -for socket and I/O channel communications.
+for encrypted socket and I/O channel communications. + +package require Tcl ?8.5?
-package require tls
+
package require Tcl ?8.5-?
+package require tls ?1.8-?
tls::init ?options?
tls::socket ?options? host port
tls::socket ?-server command? ?options? port
tls::status ?-local? channel
@@ -65,146 +66,136 @@
tls::unimport channel
tls::protocols
tls::version
This extension provides TCL script access to secure socket communications using the Transport Layer Security (TLS) protocol. It provides a generic -binding to OpenSSL, utilizing the -Tcl_StackChannel API in Tcl 8.4 and higher. +binding to OpenSSL, utilizing the +Tcl_StackChannel API in TCL 8.4 and higher. These sockets behave exactly the same as channels created using the built-in socket command, along with additional options for controlling -the SSL session. +the SSL/TLS session.
+ +Typically one would use the tls::socket command -which provides compatibility with the native Tcl socket +which provides compatibility with the native TCL socket command. In such cases tls::import should not be used directly.
--+ argument (default is false). ++
- This is a helper function that utilizes the underlying commands + (socket and tls::import) to create + the connection. It behaves the same as the native TCL socket + command, but also supports the tls:import + command options and one additional option:
+-
- -autoservername bool
- Automatically set the -servername argument to the host - argument (default is false).
-
-- ++
-
- -alpn list
- List of protocols to offer during Application-Layer Protocol Negotiation (ALPN). For example: h2 and http/1.1, but not h3 or quic.
- -cadir dir
-- Set the CA certificates path. The default directory is platform - specific and can be set at compile time. This can be overridden - via the SSL_CERT_DIR environment variable.
+- Specifies the directory where the Certificate Authority (CA) + certificates are stored. The default is platform specific and can be + set at compile time. This can be overridden via the SSL_CERT_DIR + environment variable.
- -cafile filename
-- Set the certificate authority (CA) certificates file. The default - is the cert.pem file in the OpsnSSL directory. This can also be - overridden via the SSL_CERT_FILE environment variable.
+- Specifies the file with the Certificate Authority (CA) certificates + to use. The default is cert.pem, in the OpenSSL directory. This can + also be overridden via the SSL_CERT_FILE environment variable.
- -certfile filename
-- Specify the filename with the certificate to use.
-- -cert filename
-- Specify the contents of a certificate to use, as a DER - encoded binary value (X.509 DER).
+- Specifies the file with the certificate to use in PEM format. + This also contains the public key.
+- -cert binary_string
+- Specifies the certificate to use as a DER encoded string (X.509 DER).
- -cipher string
-- List of ciphers to use. String is a colon (":") separated list - of ciphers. Ciphers can be combined - using the + character. Prefixes can be used to permanently - remove ("!"), delete ("-"), or move a cypher to the end of - the list ("+"). Keywords @STRENGTH (sort by algorithm - key length), @SECLEVEL=n (set security level to - n), and DEFAULT (use default cipher list, at start only) - can also be specified. See OpenSSL documentation for the full - list of valid values. (TLS 1.2 and earlier only)
+- Specifies the list of ciphers to use for TLS 1.2 and earlier. String is a + colon (":") separated list of ciphers. Ciphers can be combined using the + + character. Prefixes can be used to permanently remove ("!"), + delete ("-"), or move a cipher to the end of the list ("+"). Keywords + @STRENGTH (sort by algorithm key length), @SECLEVEL=n + (set security level to n), and DEFAULT (use default cipher list, + at start only) can also be specified. See OpenSSL documentation for the + full list of valid values.
- -ciphersuites string
-- List of cipher suites to use. String is a colon (":") - separated list of cipher suite names. (TLS 1.3 only)
+- Specifies the list of cipher suites to use for TLS 1.3. String is a colon + (":") separated list of cipher suite names.
- -command callback
-- Callback command to invoke at several points during the handshake. - This is used to pass errors and tracing information, and - it can allow Tcl scripts to perform their own certificate - validation in place of the default validation provided by - OpenSSL. See CALLBACK OPTIONS - for further discussion.
+- Specifies the callback command to be invoked at several points during the + handshake to pass errors, tracing information, and protocol messages. + See CALLBACK OPTIONS for more info.
- -dhparams filename
-- Specify the Diffie-Hellman parameters file.
+- Specifies the Diffie-Hellman (DH) parameters file.
- -keyfile filename
-- Specify the private key file. (default is - value of -certfile)
+- Specifies the private key file. (default is value of -certfile).
- -key filename
-- Specify the private key to use as a DER encoded value (PKCS#1 DER)
+- Specifies the private key to use as a DER encoded string (PKCS#1 DER).
- -model channel
- Force this channel to share the same SSL_CTX structure as the specified channel, and therefore share callbacks etc.
- -password callback
-- Callback command to invoke when OpenSSL needs to obtain a password. - Typically used to unlock the private key of a certificate. The - callback should return a string which represents the password - to be used. See CALLBACK OPTIONS - for further discussion.
+- Specifies the callback command to invoke when OpenSSL needs to + obtain a password. This is typically used to unlock the private key of + a certificate. The callback should return a password string. + See CALLBACK OPTIONS for more info.
- -post_handshake bool
-- Allow post-handshake ticket updates.
+- Allow post-handshake session ticket updates.
- -request bool
-- Request a certificate from peer during SSL handshake. - (default is true)
+- Request a certificate from peer during the SSL handshake. This is + needed to do certificate validation. (default is true)
- -require bool
-- Require a valid certificate from peer during SSL handshake. - If this is set to true, then -request must - also be set to true and a either a -cadir, -cafile, or platform - default must be provided in order to validate against. - (default is false)
+- Require a valid certificate from peer during SSL handshake. If this + is set to true, then -request must also be set to true + and a either a -cadir, -cafile, or platform default must be provided in + order to validate against. (default is false)
- -security_level integer
-- Set security level. Must be 0 to 5. The security level affects - the cipher suite encryption algorithms, supported ECC curves, - supported signature algorithms, DH parameter sizes, certificate - key sizes and signature algorithms. The default is 1. - Level 3 and higher disable support for session tickets and only - accept cipher suites that provide forward secrecy.
+- Specifies the security level (value from 0 to 5). The security level + affects the cipher suite encryption algorithms, supported ECC curves, + supported signature algorithms, DH parameter sizes, certificate key + sizes and signature algorithms. The default is 1. Level 3 and higher + disable support for session tickets and only accept cipher suites that + provide forward secrecy.
- -server bool
-- Set to act as a server and respond with a server handshake when - a client connects and provides a client handshake. +
- Specifies whether to act as a server and respond with a server + handshake when a client connects and provides a client handshake. (default is false)
- -servername host
-- Specify server's hostname. Used to set the TLS 'Server Name - Indication' (SNI) extension. Set to the expected servername - in the server's certificate or one of the subjectAltName - alternates.
+- Specify server's hostname. This is used to set the TLS Server Name + Indication (SNI) extension. Set this to the expected servername in the + server's certificate or one of the subjectAltName alternates.
- -session_id string
-- Session id to resume session.
+- Specifies the session id to resume session.
- -ssl2 bool
- Enable use of SSL v2. (default is false)
- -ssl3 bool
- Enable use of SSL v3. (default is false)
- -tls1 bool
@@ -214,44 +205,44 @@- -tls1.2 bool
- Enable use of TLS v1.2 (default is true)
- -tls1.3 bool
- Enable use of TLS v1.3 (default is true)
- -validatecommand callback
-- Callback command to invoke to verify or validate protocol config - parameters during the protocol negotiation phase. See - CALLBACK OPTIONS - for further discussion.
-
- SSL Status ++ SSL Status--
- alpn protocol
- The protocol selected after Application-Layer Protocol Negotiation (ALPN).
- cipher cipher
-- The current cipher in use between for the channel.
+- The current cipher in use for the session.
- peername name
- The peername from the certificate.
- protocol version
- The protocol version used for the connection: SSL2, SSL3, TLS1, TLS1.1, TLS1.2, TLS1.3, or unknown.
@@ -269,38 +260,34 @@- verifyResult result
- Certificate verification result.
- ca_names list
- List of the Certificate Authorities used to create the certificate.
- Certificate Status + Certificate Status+-
- all string
- Dump of all certificate info.
-- version value
- The certificate version.
- serialNumber n
- The serial number of the certificate as a hex string.
- signature algorithm
- Cipher algorithm used for certificate signature.
- issuer dn
- The distinguished name (DN) of the certificate issuer.
- notBefore date
-- The begin date for the validity of the certificate.
+- The beginning date of the certificate validity.
- notAfter date
-- The expiration date for the certificate.
+- The expiration date of the certificate validity.
- subject dn
- The distinguished name (DN) of the certificate subject. Fields include: Common Name (CN), Organization (O), Locality or City (L), State or Province (S), and Country Name (C).
- issuerUniqueID string
- The issuer unique id.
- subjectUniqueID string
- The subject unique id.
-- num_extensions n
- Number of certificate extensions.
- extensions list
- List of certificate extension names.
- authorityKeyIdentifier string
@@ -307,21 +294,19 @@- (AKI) Key identifier of the Issuing CA certificate that signed the SSL certificate as a hex string. This value matches the SKI value of the Intermediate CA certificate.
- subjectKeyIdentifier string
- (SKI) Hash of the public key inside the certificate as a hex - string. Used to identify certificates that contain a particular - public key.
+ string. Used to identify certificates that contain a particular + public key.- subjectAltName list
- List of all of the alternative domain names, sub domains, and IP addresses that are secured by the certificate.
- ocsp list
- List of all Online Certificate Status Protocol (OCSP) URLs.
-- certificate cert
- The PEM encoded certificate.
-- signatureAlgorithm algorithm
- Cipher algorithm used for the certificate signature.
- signatureValue string
- Certificate signature as a hex string.
- signatureDigest version
@@ -332,24 +317,23 @@- Certificate signature public key as a hex string.
- bits n
- Number of bits used for certificate signature key.
- self_signed boolean
- Whether the certificate signature is self signed.
-- sha1_hash hash
- The SHA1 hash of the certificate as a hex string.
- sha256_hash hash
- The SHA256 hash of the certificate as a hex string.
- SSL Status ++ SSL Status--
- state state
- State of the connection.
- servername name
- The name of the connected to server.
@@ -369,13 +353,11 @@- expansion mode
- Expansion method.
- caList list
- List of Certificate Authorities (CA) for X.509 certificate.
- Cipher Info + Cipher Info--
- cipher cipher
- The current cipher in use for the connection.
- standard_name name
- The standard RFC name of cipher.
@@ -385,21 +367,19 @@- The number of secret bits used for cipher.
- min_version version
- The minimum protocol version for cipher.
- cipher_is_aead boolean
- Whether the cipher is Authenticated Encryption with - Associated Data (AEAD).
+ Associated Data (AEAD).- cipher_id id
- The OpenSSL cipher id.
- description string
- A text description of the cipher.
- handshake_digest boolean
- Digest used during handshake.
- Session Info + Session Info+-
- alpn protocol
- The protocol selected after Application-Layer Protocol Negotiation (ALPN).
- resumable boolean
@@ -419,21 +399,23 @@- master_key binary_string
- Unique session master key.
- session_cache_mode mode
- Server cache mode (client, server, or both).
As indicated above, individual channels can be given their own callbacks @@ -443,251 +425,223 @@ tls::socket or tls::import. If the callback generates an error, the bgerror command will be invoked with the error information.
--
+- -command callback
- Invokes the specified callback script at several points during the OpenSSL handshake and use. See below for the possible arguments passed to the callback script. Values returned from the callback are ignored. - -
- -
-
- -- -
-- - error channelId message -
-- - This form of callback is invoked whenever an error occurs during the - initial connection, handshake, or I/O operations. The message - argument can be from the Tcl_ErrnoMsg, OpenSSL function -
- -ERR_reason_error_string()
, or a custom message. -
- -- - info channelId major minor message type -
-- - This form of callback is invoked by the OpenSSL function -
- -SSL_set_info_callback()
during the initial connection - and handshake operations. The type argument is new for - TLS 1.8. The arguments are: -
--
-- Possible values for major are: -
-handshake, alert, connect, accept
.- Possible values for minor are: -
-start, done, read, write, loop, exit
.- The message argument is a descriptive string which may - be generated either by
-SSL_state_string_long()
or by -SSL_alert_desc_string_long()
, depending on the context.- For alerts, the possible values for type are: -
-warning, fatal, and unknown
. For others, -info
is used.- - message channelId direction version content_type message -
-- - This form of callback is invoked by the OpenSSL function -
-SSL_set_msg_callback()
whenever a message is sent or - received during the initial connection, handshake, or I/O operations. - It is only available when OpenSSL is complied with the - enable-ssl-trace option. Arguments are: direction - is Sent or Received, version is the protocol - version, content_type is the message content type, and - message is more info from theSSL_trace
API. - This callback is new for TLS 1.8. -
- -- - session channelId session_id ticket lifetime -
-- - This form of callback is invoked by the OpenSSL function -
-SSL_CTX_sess_set_new_cb()
whenever a new session id is - sent by the server during the initial connection and handshake, but - can also be received later if the -post_handshake option is - used. Arguments are: session_id is the current - session identifier, ticket is the session ticket info, and - lifetime is the the ticket lifetime in seconds. - This callback is new for TLS 1.8. -
-
- +
++
+ +- + error channelId message +
+- + This form of callback is invoked whenever an error occurs during the + initial connection, handshake, or I/O operations. The message + argument can be from the Tcl_ErrnoMsg, OpenSSL function +
+ERR_reason_error_string()
, or a custom message. +
+- + info channelId major minor message type +
+- + This form of callback is invoked by the OpenSSL function +
+SSL_set_info_callback()
during the initial connection + and handshake operations. The type argument is new for + TLS 1.8. The arguments are: +
++
+- Possible values for major are: +
+handshake, alert, connect, accept
.- Possible values for minor are: +
+start, done, read, write, loop, exit
.- The message argument is a descriptive string which may + be generated either by
+SSL_state_string_long()
or by +SSL_alert_desc_string_long()
, depending on the context.- For alerts, the possible values for type are: +
+warning, fatal, and unknown
. For others, +info
is used.- + message channelId direction version content_type message +
+- + This form of callback is invoked by the OpenSSL function +
+SSL_set_msg_callback()
whenever a message is sent or + received during the initial connection, handshake, or I/O operations. + It is only available when OpenSSL is complied with the + enable-ssl-trace option. Arguments are: direction + is Sent or Received, version is the protocol + version, content_type is the message content type, and + message is more info from theSSL_trace
API. + This callback is new for TLS 1.8. +
+- + session channelId session_id ticket lifetime +
+- + This form of callback is invoked by the OpenSSL function +
+SSL_CTX_sess_set_new_cb()
whenever a new session id is + sent by the server during the initial connection and handshake, but + can also be received later if the -post_handshake option is + used. Arguments are: session_id is the current + session identifier, ticket is the session ticket info, and + lifetime is the the ticket lifetime in seconds. + This callback is new for TLS 1.8. +
++ + +
- -password callback
- Invokes the specified callback script when OpenSSL needs to obtain a password. See below for the possible arguments passed to the callback script. See below for valid return values. -
- -
-
-- -
- - password rwflag size -
-- - Invoked when loading or storing a PEM certificate with encryption. - Where rwflag is 0 for reading/decryption or 1 for - writing/encryption (can prompt user to confirm) and - size is the max password length in bytes. - The callback should return the password as a string. - Both arguments are new for TLS 1.8. -
-
- - +- + password rwflag size +
+- + Invoked when loading or storing a PEM certificate with encryption. + Where rwflag is 0 for reading/decryption or 1 for + writing/encryption (can prompt user to confirm) and size is + the max password length in bytes. The callback should return the + password as a string. Both arguments are new for TLS 1.8. +
+
+-
- -validatecommand callback
- Invokes the specified callback script during handshake in order to validate the provided value(s). See below for the possible arguments passed to the callback script. If not specified, OpenSSL will accept valid certificates and extensions. To reject the value and abort the connection, the callback should return 0. To accept the value and continue the connection, it should return 1. To reject the value, but continue the connection, it should return 2. -
-
-- -
- - alpn channelId protocol match -
-- - For servers, this form of callback is invoked when the client ALPN - extension is received. If match is true, protocol - is the first -alpn option specified protocol common to both - the client and server. If not, the first client specified protocol is - used. It is called after the hello and ALPN callbacks. - This callback is new for TLS 1.8. -
- -
- -- - hello channelId servername -
-- - For servers, this form of callback is invoked during client hello - message processing. The purpose is so the server can select the - appropriate certificate to present to the client, and to make other - configuration adjustments relevant to that server name and its - configuration. It is called before the SNI and ALPN callbacks. - This callback is new for TLS 1.8. -
- -
- -- - sni channelId servername -
-- - For servers, this form of callback is invoked when the Server Name - Indication (SNI) extension is received. The servername - argument is the client provided server name in the -servername - option. The purpose is so when a server supports multiple names, the - right certificate can be used. It is called after the hello callback - but before the ALPN callback. - This callback is new for TLS 1.8. -
- -
- -- - verify channelId depth cert status error -
-- - This form of callback is invoked by OpenSSL when a new certificate - is received from the peer. It allows the client to check the - certificate verification results and choose whether to continue - or not. It is called for each certificate in the certificate chain. -
--
-- The depth argument is the integer depth of the - certificate in the certificate chain, where 0 is the peer certificate - and higher values going up to the Certificate Authority (CA).
-- The cert argument is a list of key-value pairs similar - to those returned by - tls::status.
-- The status argument is the boolean validity of the - current certificate where 0 is invalid and 1 is valid.
-- The error argument is the error message, if any, generated - by
-X509_STORE_CTX_get_error()
.
+- + alpn channelId protocol match +
+- + For servers, this form of callback is invoked when the client ALPN + extension is received. If match is true, protocol + is the first -alpn option specified protocol common to both + the client and server. If not, the first client specified protocol is + used. It is called after the hello and ALPN callbacks. + This callback is new for TLS 1.8. +
+
+- + hello channelId servername +
+- + For servers, this form of callback is invoked during client hello + message processing. The purpose is so the server can select the + appropriate certificate to present to the client, and to make other + configuration adjustments relevant to that server name and its + configuration. It is called before the SNI and ALPN callbacks. + This callback is new for TLS 1.8. +
+
+- + sni channelId servername +
+- + For servers, this form of callback is invoked when the Server Name + Indication (SNI) extension is received. The servername + argument is the client provided server name in the -servername + option. The purpose is so when a server supports multiple names, the + right certificate can be used. It is called after the hello callback + but before the ALPN callback. + This callback is new for TLS 1.8. +
+
+- + verify channelId depth cert status error +
+- + This form of callback is invoked by OpenSSL when a new certificate + is received from the peer. It allows the client to check the + certificate verification results and choose whether to continue + or not. It is called for each certificate in the certificate chain. +
++
+- The depth argument is the integer depth of the + certificate in the certificate chain, where 0 is the peer certificate + and higher values going up to the Certificate Authority (CA).
+- The cert argument is a list of key-value pairs similar + to those returned by + tls::status.
+- The status argument is the boolean validity of the + current certificate where 0 is invalid and 1 is valid.
+- The error argument is the error message, if any, generated + by
+X509_STORE_CTX_get_error()
.
Reference implementations of these callbacks are provided in the distribution as tls::callback, tls::password, -and tls::validate_command respectively. Note that these are -sample implementations only. In a more realistic deployment +and tls::validate_command respectively. Note that these are +sample implementations only. In a more realistic deployment you would specify your own callback scripts on each TLS channel using the --command, -password, and -validate_command options. +-command, -password, and +-validate_command options.
-The default behavior when the -command and -validate_command options are not specified is for TLS to process the associated library callbacks internally. The default behavior when the -password option is not specified is for TLS to process the associated library callbacks by attempting to call tls::password. The difference between these two behaviors is a consequence of maintaining compatibility with earlier implementations.
-The use of the reference callbacks tls::callback, tls::password, and tls::validate_command -is not recommended. They may be removed from future releases. +is not recommended. They may be removed from future releases.
+ +The tls::debug variable provides some additional -control over these reference callbacks. Its value is zero by default. +control over these reference callbacks. Its value is zero by default. Higher values produce more diagnostic output, and will also force the verify method in tls::callback to accept the certificate, even when it is invalid if the tls::validate_command callback is used for the -validatecommand option.
-The use of the variable tls::debug is not recommended. It may be removed from future releases. @@ -697,13 +651,12 @@
These examples use the default Unix platform SSL certificates. For standard installations, -cadir and -cafile should not be needed. If your certificates are in non-standard locations, update -cadir or use -cafile as needed.
Example #1: Use HTTP package
package require http
package require tls
set url "https://www.tcl.tk/"
@@ -722,11 +675,11 @@
# Cleanup
::http::cleanup $token
-Example #2: Use raw socket
+Example #2: Use raw socket
package require tls
set url "www.tcl-lang.org"
set port 443
@@ -749,19 +702,19 @@
parray status
parray conn
parray chan
+These examples use the default Unix platform SSL certificates. For standard installations, -cadir and -cafile should not be needed. If your certificates are in non-standard locations, update -cadir or use -cafile as needed.
-Example #1: Get web page - +Example #1: Get web page
package require http
package require tls
set url "https://www.tcl.tk/"
@@ -779,12 +732,11 @@
# Cleanup
::http::cleanup $token
-Example #2: Download file
-
+Example #2: Download file
package require http
package require tls
set url "https://wiki.tcl-lang.org/sitemap.xml"
@@ -798,23 +750,27 @@
# Cleanup
close $ch
::http::cleanup $token
+
+The capabilities of this package can vary enormously based upon how the linked to OpenSSL library was configured and built. New versions may obsolete older protocol versions, add or remove ciphers, change default values, etc. Use the tls::protocols commands to obtain the supported protocol versions.
+ +socket, fileevent, http, -OpenSSL
+OpenSSLCopyright © 1999 Matt Newman. Index: generic/tls.c ================================================================== --- generic/tls.c +++ generic/tls.c @@ -25,16 +25,11 @@ #include "tlsInt.h" #include "tclOpts.h" #include "tlsUuid.h" #include#include -#include -#include -#include -#include -#include -#include + /* Min OpenSSL version */ #if OPENSSL_VERSION_NUMBER < 0x10101000L #error "Only OpenSSL v1.1.1 or later is supported" #endif @@ -162,11 +157,11 @@ static void InfoCallback(const SSL *ssl, int where, int ret) { State *statePtr = (State*)SSL_get_app_data((SSL *)ssl); Tcl_Interp *interp = statePtr->interp; Tcl_Obj *cmdPtr; - char *major; char *minor; + char *major, *minor; dprintf("Called"); if (statePtr->callback == (Tcl_Obj*)NULL) return; @@ -1306,12 +1301,10 @@ statePtr->ctx = ctx; /* * We need to make sure that the channel works in binary (for the * encryption not to get goofed up). - * We only want to adjust the buffering in pre-v2 channels, where - * each channel in the stack maintained its own buffers. */ Tcl_DStringInit(&upperChannelTranslation); Tcl_DStringInit(&upperChannelBlocking); Tcl_DStringInit(&upperChannelEOFChar); Tcl_DStringInit(&upperChannelEncoding); @@ -1322,19 +1315,23 @@ Tcl_SetChannelOption(interp, chan, "-translation", "binary"); Tcl_SetChannelOption(interp, chan, "-blocking", "true"); dprintf("Consuming Tcl channel %s", Tcl_GetChannelName(chan)); statePtr->self = Tcl_StackChannel(interp, Tls_ChannelType(), (ClientData) statePtr, (TCL_READABLE | TCL_WRITABLE), chan); - dprintf("Created channel named %s", Tcl_GetChannelName(statePtr->self)); if (statePtr->self == (Tcl_Channel) NULL) { /* * No use of Tcl_EventuallyFree because no possible Tcl_Preserve. */ Tls_Free((tls_free_type *) statePtr); + Tcl_DStringFree(&upperChannelTranslation); + Tcl_DStringFree(&upperChannelEncoding); + Tcl_DStringFree(&upperChannelEOFChar); + Tcl_DStringFree(&upperChannelBlocking); return TCL_ERROR; } + dprintf("Created channel named %s", Tcl_GetChannelName(statePtr->self)); Tcl_SetChannelOption(interp, statePtr->self, "-translation", Tcl_DStringValue(&upperChannelTranslation)); Tcl_SetChannelOption(interp, statePtr->self, "-encoding", Tcl_DStringValue(&upperChannelEncoding)); Tcl_SetChannelOption(interp, statePtr->self, "-eofchar", Tcl_DStringValue(&upperChannelEOFChar)); Tcl_SetChannelOption(interp, statePtr->self, "-blocking", Tcl_DStringValue(&upperChannelBlocking)); Tcl_DStringFree(&upperChannelTranslation); @@ -1443,11 +1440,10 @@ /* * SSL Callbacks */ SSL_set_app_data(statePtr->ssl, (void *)statePtr); /* point back to us */ - SSL_set_verify(statePtr->ssl, verify, VerifyCallback); SSL_set_info_callback(statePtr->ssl, InfoCallback); /* Callback for observing protocol messages */ #ifndef OPENSSL_NO_SSL_TRACE @@ -1535,40 +1531,72 @@ * *------------------------------------------------------------------- */ static int UnimportObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Tcl_Channel chan; /* The channel to set a mode on. */ + Tcl_Channel chan, child; /* The stacked and underlying channels */ + Tcl_DString upperChannelTranslation, upperChannelBlocking, upperChannelEncoding, upperChannelEOFChar; + int res = TCL_OK; (void) clientData; dprintf("Called"); if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "channel"); return TCL_ERROR; } + /* Validate channel name */ chan = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), NULL); if (chan == (Tcl_Channel) NULL) { return TCL_ERROR; } /* Make sure to operate on the topmost channel */ chan = Tcl_GetTopChannel(chan); + child = Tcl_GetStackedChannel(chan); - if (Tcl_GetChannelType(chan) != Tls_ChannelType()) { + /* Verify is a stacked channel */ + if (child == NULL) { Tcl_AppendResult(interp, "bad channel \"", Tcl_GetChannelName(chan), - "\": not a TLS channel", (char *) NULL); + "\": not a stacked channel", (char *) NULL); Tcl_SetErrorCode(interp, "TLS", "UNIMPORT", "CHANNEL", "INVALID", (char *) NULL); return TCL_ERROR; } - if (Tcl_UnstackChannel(interp, chan) == TCL_ERROR) { + /* Flush any pending data */ + if (Tcl_Flush(chan) != TCL_OK) { return TCL_ERROR; } - return TCL_OK; + Tcl_DStringInit(&upperChannelTranslation); + Tcl_DStringInit(&upperChannelBlocking); + Tcl_DStringInit(&upperChannelEOFChar); + Tcl_DStringInit(&upperChannelEncoding); + + /* Get current config - EOL translation, encoding and buffering options are shared between all channels in the stack */ + Tcl_GetChannelOption(interp, chan, "-blocking", &upperChannelBlocking); + Tcl_GetChannelOption(interp, chan, "-encoding", &upperChannelEncoding); + Tcl_GetChannelOption(interp, chan, "-eofchar", &upperChannelEOFChar); + Tcl_GetChannelOption(interp, chan, "-translation", &upperChannelTranslation); + + /* Unstack the channel and restore underlying channel config */ + if (Tcl_UnstackChannel(interp, chan) == TCL_OK) { + Tcl_SetChannelOption(interp, child, "-encoding", Tcl_DStringValue(&upperChannelEncoding)); + Tcl_SetChannelOption(interp, child, "-eofchar", Tcl_DStringValue(&upperChannelEOFChar)); + Tcl_SetChannelOption(interp, child, "-translation", Tcl_DStringValue(&upperChannelTranslation)); + Tcl_SetChannelOption(interp, child, "-blocking", Tcl_DStringValue(&upperChannelBlocking)); + } else { + res = TCL_ERROR; + } + + /* Clean-up */ + Tcl_DStringFree(&upperChannelTranslation); + Tcl_DStringFree(&upperChannelEncoding); + Tcl_DStringFree(&upperChannelEOFChar); + Tcl_DStringFree(&upperChannelBlocking); + return res; } /* *------------------------------------------------------------------- * @@ -2050,17 +2078,20 @@ res = SSL_get_signature_nid(statePtr->ssl, &nid); } if (!res) {nid = 0;} LAPPEND_STR(interp, objPtr, "signatureHashAlgorithm", OBJ_nid2ln(nid), -1); + /* Added in OpenSSL 1.1.1a */ +#if OPENSSL_VERSION_NUMBER > 0x10101000L if (objc == 2) { res = SSL_get_peer_signature_type_nid(statePtr->ssl, &nid); } else { res = SSL_get_signature_type_nid(statePtr->ssl, &nid); } if (!res) {nid = 0;} LAPPEND_STR(interp, objPtr, "signatureType", OBJ_nid2ln(nid), -1); +#endif Tcl_SetObjResult(interp, objPtr); return TCL_OK; } @@ -2742,10 +2773,11 @@ Tcl_CreateObjCommand(interp, "::tls::connection", ConnectionInfoObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::handshake", HandshakeObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::import", ImportObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::misc", MiscObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::unimport", UnimportObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "::tls::unstack", UnimportObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::status", StatusObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); BuildInfoCommand(interp); Tls_DigestCommands(interp); Tls_EncryptCommands(interp); @@ -2857,36 +2889,11 @@ OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS | OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL); BIO_new_tcl(NULL, 0); -#if 0 - /* - * XXX:TODO: Remove this code and replace it with a check - * for enough entropy and do not try to create our own - * terrible entropy - */ - /* - * Seed the random number generator in the SSL library, - * using the do/while construct because of the bug note in the - * OpenSSL FAQ at http://www.openssl.org/support/faq.html#USER1 - * - * The crux of the problem is that Solaris 7 does not have a - * /dev/random or /dev/urandom device so it cannot gather enough - * entropy from the RAND_seed() when TLS initializes and refuses - * to go further. Earlier versions of OpenSSL carried on regardless. - */ - srand((unsigned int) time((time_t *) NULL)); - do { - for (i = 0; i < 16; i++) { - rnd_seed[i] = 1 + (char) (255.0 * rand()/(RAND_MAX+1.0)); - } - RAND_seed(rnd_seed, sizeof(rnd_seed)); - } while (RAND_status() != 1); -#endif - #if defined(OPENSSL_THREADS) && defined(TCL_THREADS) Tcl_MutexUnlock(&init_mx); #endif return status; } Index: generic/tlsInt.h ================================================================== --- generic/tlsInt.h +++ generic/tlsInt.h @@ -1,35 +1,44 @@ /* + *---------------------------------------------------------------------- * Copyright (C) 1997-2000 Matt Newman * - * TLS (aka SSL) Channel - can be layered on any bi-directional - * Tcl_Channel (Note: Requires Trf Core Patch) - * - * This was built from scratch based upon observation of OpenSSL 0.9.2B + * Macro and structure definitions * * Addition credit is due for Andreas Kupries (a.kupries@westend.com), for * providing the Tcl_ReplaceChannel mechanism and working closely with me * to enhance it to support full fileevent semantics. * * Also work done by the follow people provided the impetus to do this "right":- * tclSSL (Colin McCormack, Shared Technology) * SSLtcl (Peter Antman) - * + *---------------------------------------------------------------------- */ #ifndef _TLSINT_H #define _TLSINT_H + +/* Platform unique definitions */ +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include /* OpenSSL needs this on Windows */ +#endif #include "tls.h" #include #include #include +#include +#include +#include +#include -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#include /* OpenSSL needs this on Windows */ -#endif +/* Windows needs to know which symbols to export. */ +#ifdef BUILD_tls +#undef TCL_STORAGE_CLASS +#define TCL_STORAGE_CLASS DLLEXPORT +#endif /* BUILD_udp */ /* Handle TCL 8.6 CONST changes */ #ifndef CONST86 # if TCL_MAJOR_VERSION > 8 # define CONST86 const @@ -53,22 +62,19 @@ #define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj #define Tcl_NewSizeIntObj Tcl_NewIntObj #define Tcl_NewSizeIntFromObj Tcl_NewWideIntObj #endif -#include -#include -#include -#include - +/* Define missing POSIX error codes */ #ifndef ECONNABORTED #define ECONNABORTED 130 /* Software caused connection abort */ #endif #ifndef ECONNRESET #define ECONNRESET 131 /* Connection reset by peer */ #endif +/* Debug and error macros */ #ifdef TCLEXT_TCLTLS_DEBUG #include #define dprintf(...) { \ char dprintfBuffer[8192], *dprintfBuffer_p; \ dprintfBuffer_p = &dprintfBuffer[0]; \ Index: pkgIndex.tcl.in ================================================================== --- pkgIndex.tcl.in +++ pkgIndex.tcl.in @@ -1,25 +1,32 @@ # -*- tcl -*- # Tcl package index file, version 1.1 # if {[package vsatisfies [package provide Tcl] 9.0-]} { - package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \ - [list load [file join $dir @PKG_LIB_FILE9@] [string totitle @PACKAGE_NAME@]] - set initScript [file join $dir @PACKAGE_NAME@.tcl] - if {[file exists $initScript]} { - source -encoding utf-8 $initScript - } + package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ [list apply {{dir} { + # Load library + load [file join $dir @PKG_LIB_FILE9@] [string totitle @PACKAGE_NAME@] + + # Source init file + set initScript [file join $dir @PACKAGE_NAME@.tcl] + if {[file exists $initScript]} { + source -encoding utf-8 $initScript + } + }} $dir] } else { if {![package vsatisfies [package provide Tcl] 8.5]} {return} package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ [list apply {{dir} { + # Load library if {[string tolower [file extension @PKG_LIB_FILE8@]] in [list .dll .dylib .so]} { # Load dynamic library load [file join $dir @PKG_LIB_FILE8@] [string totitle @PACKAGE_NAME@] } else { # Static library load {} [string totitle @PACKAGE_NAME@] } + + # Source init file set initScript [file join $dir @PACKAGE_NAME@.tcl] if {[file exists $initScript]} { source -encoding utf-8 $initScript } }} $dir] Index: win/makefile.vc ================================================================== --- win/makefile.vc +++ win/makefile.vc @@ -1,22 +1,26 @@ #------------------------------------------------------------- -*- makefile -*- # -# Makefile for TclTLS extensions. +# Makefile for TCL TLS extension # # Basic build, test and install -# nmake /f makefile.vc INSTALLDIR=c:\path\to\tcl -# nmake /f makefile.vc INSTALLDIR=c:\path\to\tcl test -# nmake /f makefile.vc INSTALLDIR=c:\path\to\tcl install +# nmake /f makefile.vc INSTALLDIR=c:\path\to\tcl TCLDIR=c:\path\to\tcl\sources +# nmake /f makefile.vc INSTALLDIR=c:\path\to\tcl TCLDIR=c:\path\to\tcl\sources test +# nmake /f makefile.vc INSTALLDIR=c:\path\to\tcl TCLDIR=c:\path\to\tcl\sources install # # For other build options (debug, static etc.), # See TIP 477 (https://core.tcl-lang.org/tips/doc/main/tip/477.md) for # detailed documentation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # #------------------------------------------------------------------------------ + +#------------------------------------------------------------------------- +# Project specific information +#------------------------------------------------------------------------- # The name of the package PROJECT=tls !include "rules-ext.vc" @@ -36,14 +40,14 @@ $(TMP_DIR)\tlsUtil.obj \ $(TMP_DIR)\tlsX509.obj # Define any additional project include flags # SSL_INSTALL_FOLDER = with the OpenSSL installation folder following. -PRJ_INCLUDES = -I"$(SSL_INSTALL_FOLDER)\include" -I"$(OPENSSL_INSTALL_DIR)\include" +PRJ_INCLUDES = -I"$(SSL_INSTALL_FOLDER)\include" -I"$(OPENSSL_INSTALL_DIR)\include" -I"$(TMP_DIR)" # Define any additional compiler flags that might be required for the project -PRJ_DEFINES = -D NO_SSL2 -D NO_SSL3 -D _CRT_SECURE_NO_WARNINGS +PRJ_DEFINES = -D NO_SSL2 -D NO_SSL3 /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D__STDC_WANT_SECURE_LIB__=1 # # SSL Libs: # 1. ${LIBCRYPTO}.dll # 2. ${LIBSSL}.dll @@ -53,50 +57,59 @@ # On *nix libcrypto.so.* and libssl.so.* (where suffix is a version indicator). # PRJ_LIBS = \ "$(SSL_INSTALL_FOLDER)\lib\libssl.lib" \ "$(SSL_INSTALL_FOLDER)\lib\libcrypto.lib" \ - WS2_32.LIB GDI32.LIB ADVAPI32.LIB CRYPT32.LIB USER32.LIB + User32.Lib WS2_32.Lib Gdi32.Lib AdvAPI32.Lib Crypt32.Lib -# Define the standard targets +# Define the standard targets which calls rules.vc !include "targets.vc" +#--------------------------------------------------------------------- # Project specific targets +#--------------------------------------------------------------------- -all: default-target +all: setup default-target clean: default-clean - @if exist $(WIN_DIR)\tlsUuid.h del $(WIN_DIR)\tlsUuid.h realclean: default-hose - @if exist $(WIN_DIR)\tlsUuid.h del $(WIN_DIR)\tlsUuid.h # We must define a pkgindex target that will create a pkgIndex.tcl # file in the $(OUT_DIR) directory. We can just redirect to the # default-pkgindex target for our sample extension. pkgindex: default-pkgindex-tea +# Manifest which defines fossil/git commit id for build-info command $(ROOT)\manifest.uuid: - copy $(WIN_DIR)\gitmanifest.in $(ROOT)\manifest.uuid - git rev-parse HEAD >>$(ROOT)\manifest.uuid + if not exist $(ROOT)\manifest.uuid ( + copy $(WIN_DIR)\gitmanifest.in $(ROOT)\manifest.uuid + where git + if ERRORLEVEL 0 ( + git rev-parse HEAD >>$(ROOT)\manifest.uuid + ) else ( + echo unknown >>$(ROOT)\manifest.uuid + ) + ) -$(WIN_DIR)\tlsUuid.h: $(ROOT)\manifest.uuid - copy $(WIN_DIR)\tlsUuid.h.in+$(ROOT)\manifest.uuid $(WIN_DIR)\tlsUuid.h +$(TMP_DIR)\tlsUuid.h: $(ROOT)\manifest.uuid + copy $(WIN_DIR)\tlsUuid.h.in+$(ROOT)\manifest.uuid $(TMP_DIR)\tlsUuid.h + echo: >>$(TMP_DIR)\tlsUuid.h # The default install target only installs binaries and scripts so add # an additional target for our documentation. Note this *adds* a target # since no commands are listed after it. The original targets for # install (from targets.vc) will remain. -install: default-pkgindex-tea default-install default-install-docs-html +install: pkgindex default-install default-install-docs-html if exist "$(SSL_INSTALL_FOLDER)\bin\libcrypto-*-x64.dll" ( xcopy /c /y "$(SSL_INSTALL_FOLDER)\bin\libcrypto-*-x64.dll" "$(PRJ_INSTALL_DIR)" ) if exist "$(SSL_INSTALL_FOLDER)\bin\libssl-*-x64.dll" ( xcopy /c /y "$(SSL_INSTALL_FOLDER)\bin\libssl-*-x64.dll" "$(PRJ_INSTALL_DIR)" ) # Explicit dependency rules -$(GENERICDIR)\tls.c: $(WIN_DIR)\tlsUuid.h +$(GENERICDIR)\tls.c: $(TMP_DIR)\tlsUuid.h # Test package test: default-test