summaryrefslogtreecommitdiff
path: root/src/lib/libtls
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libtls')
-rw-r--r--src/lib/libtls/man/tls_accept_socket.35
-rw-r--r--src/lib/libtls/man/tls_client.35
-rw-r--r--src/lib/libtls/man/tls_config_ocsp_require_stapling.35
-rw-r--r--src/lib/libtls/man/tls_config_set_protocols.36
-rw-r--r--src/lib/libtls/man/tls_config_set_session_id.35
-rw-r--r--src/lib/libtls/man/tls_config_verify.35
-rw-r--r--src/lib/libtls/man/tls_conn_version.35
-rw-r--r--src/lib/libtls/man/tls_connect.35
-rw-r--r--src/lib/libtls/man/tls_init.35
-rw-r--r--src/lib/libtls/man/tls_load_file.35
-rw-r--r--src/lib/libtls/man/tls_ocsp_process_response.35
-rw-r--r--src/lib/libtls/man/tls_read.35
-rw-r--r--src/lib/libtls/shlib_version4
-rw-r--r--src/lib/libtls/tls.c4
-rw-r--r--src/lib/libtls/tls_client.c4
-rw-r--r--src/lib/libtls/tls_config.c6
-rw-r--r--src/lib/libtls/tls_conninfo.c6
-rw-r--r--src/lib/libtls/tls_keypair.c15
-rw-r--r--src/lib/libtls/tls_ocsp.c19
-rw-r--r--src/lib/libtls/tls_server.c12
-rw-r--r--src/lib/libtls/tls_signer.c18
-rw-r--r--src/lib/libtls/tls_util.c4
-rw-r--r--src/lib/libtls/tls_verify.c6
23 files changed, 95 insertions, 64 deletions
diff --git a/src/lib/libtls/man/tls_accept_socket.3 b/src/lib/libtls/man/tls_accept_socket.3
index 931b9346ec..8922708e0f 100644
--- a/src/lib/libtls/man/tls_accept_socket.3
+++ b/src/lib/libtls/man/tls_accept_socket.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_accept_socket.3,v 1.4 2018/05/26 12:35:26 schwarze Exp $ 1.\" $OpenBSD: tls_accept_socket.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: May 26 2018 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_ACCEPT_SOCKET 3 20.Dt TLS_ACCEPT_SOCKET 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_accept_cbs 25.Nm tls_accept_cbs
26.Nd accept an incoming client connection in a TLS server 26.Nd accept an incoming client connection in a TLS server
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft int 30.Ft int
30.Fo tls_accept_socket 31.Fo tls_accept_socket
diff --git a/src/lib/libtls/man/tls_client.3 b/src/lib/libtls/man/tls_client.3
index 98f58d4c20..235c779519 100644
--- a/src/lib/libtls/man/tls_client.3
+++ b/src/lib/libtls/man/tls_client.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_client.3,v 1.4 2017/08/12 03:41:48 jsing Exp $ 1.\" $OpenBSD: tls_client.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: August 12 2017 $ 17.Dd $Mdocdate: July 7 2025 $
18.Dt TLS_CLIENT 3 18.Dt TLS_CLIENT 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_free 25.Nm tls_free
26.Nd configure a TLS connection 26.Nd configure a TLS connection
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft struct tls * 30.Ft struct tls *
30.Fn tls_client void 31.Fn tls_client void
diff --git a/src/lib/libtls/man/tls_config_ocsp_require_stapling.3 b/src/lib/libtls/man/tls_config_ocsp_require_stapling.3
index a0694d304f..d776b61ad6 100644
--- a/src/lib/libtls/man/tls_config_ocsp_require_stapling.3
+++ b/src/lib/libtls/man/tls_config_ocsp_require_stapling.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_ocsp_require_stapling.3,v 1.5 2017/01/31 20:53:50 jmc Exp $ 1.\" $OpenBSD: tls_config_ocsp_require_stapling.3,v 1.6 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org> 3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org>
4.\" 4.\"
@@ -14,13 +14,14 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: January 31 2017 $ 17.Dd $Mdocdate: July 7 2025 $
18.Dt TLS_CONFIG_OCSP_REQUIRE_STAPLING 3 18.Dt TLS_CONFIG_OCSP_REQUIRE_STAPLING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm tls_config_ocsp_require_stapling 21.Nm tls_config_ocsp_require_stapling
22.Nd OCSP configuration for libtls 22.Nd OCSP configuration for libtls
23.Sh SYNOPSIS 23.Sh SYNOPSIS
24.Lb libtls libssl libcrypto
24.In tls.h 25.In tls.h
25.Ft void 26.Ft void
26.Fn tls_config_ocsp_require_stapling "struct tls_config *config" 27.Fn tls_config_ocsp_require_stapling "struct tls_config *config"
diff --git a/src/lib/libtls/man/tls_config_set_protocols.3 b/src/lib/libtls/man/tls_config_set_protocols.3
index 32b8cce757..403bc10b82 100644
--- a/src/lib/libtls/man/tls_config_set_protocols.3
+++ b/src/lib/libtls/man/tls_config_set_protocols.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_set_protocols.3,v 1.12 2023/07/02 06:37:27 beck Exp $ 1.\" $OpenBSD: tls_config_set_protocols.3,v 1.13 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015, 2016 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2015, 2016 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: July 2 2023 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_CONFIG_SET_PROTOCOLS 3 20.Dt TLS_CONFIG_SET_PROTOCOLS 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -26,10 +26,12 @@
26.Nm tls_config_set_ciphers , 26.Nm tls_config_set_ciphers ,
27.Nm tls_config_set_dheparams , 27.Nm tls_config_set_dheparams ,
28.Nm tls_config_set_ecdhecurves , 28.Nm tls_config_set_ecdhecurves ,
29.\" .Nm tls_config_set_ecdhecurve is intentionally undocumented.
29.Nm tls_config_prefer_ciphers_client , 30.Nm tls_config_prefer_ciphers_client ,
30.Nm tls_config_prefer_ciphers_server 31.Nm tls_config_prefer_ciphers_server
31.Nd TLS protocol and cipher selection 32.Nd TLS protocol and cipher selection
32.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Lb libtls libssl libcrypto
33.In tls.h 35.In tls.h
34.Ft int 36.Ft int
35.Fo tls_config_set_protocols 37.Fo tls_config_set_protocols
diff --git a/src/lib/libtls/man/tls_config_set_session_id.3 b/src/lib/libtls/man/tls_config_set_session_id.3
index d969e01e33..a869b3f24c 100644
--- a/src/lib/libtls/man/tls_config_set_session_id.3
+++ b/src/lib/libtls/man/tls_config_set_session_id.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_set_session_id.3,v 1.5 2018/02/10 06:07:43 jsing Exp $ 1.\" $OpenBSD: tls_config_set_session_id.3,v 1.6 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Claudio Jeker <claudio@openbsd.org> 3.\" Copyright (c) 2017 Claudio Jeker <claudio@openbsd.org>
4.\" Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: February 10 2018 $ 18.Dd $Mdocdate: July 7 2025 $
19.Dt TLS_CONFIG_SET_SESSION_ID 3 19.Dt TLS_CONFIG_SET_SESSION_ID 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_config_add_ticket_key 25.Nm tls_config_add_ticket_key
26.Nd configure resuming of TLS handshakes 26.Nd configure resuming of TLS handshakes
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft int 30.Ft int
30.Fo tls_config_set_session_fd 31.Fo tls_config_set_session_fd
diff --git a/src/lib/libtls/man/tls_config_verify.3 b/src/lib/libtls/man/tls_config_verify.3
index 4a43c834d7..d5b29e858e 100644
--- a/src/lib/libtls/man/tls_config_verify.3
+++ b/src/lib/libtls/man/tls_config_verify.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_config_verify.3,v 1.4 2017/03/02 11:05:50 jmc Exp $ 1.\" $OpenBSD: tls_config_verify.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: March 2 2017 $ 18.Dd $Mdocdate: July 7 2025 $
19.Dt TLS_CONFIG_VERIFY 3 19.Dt TLS_CONFIG_VERIFY 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -25,6 +25,7 @@
25.Nm tls_config_insecure_noverifytime 25.Nm tls_config_insecure_noverifytime
26.Nd insecure TLS configuration 26.Nd insecure TLS configuration
27.Sh SYNOPSIS 27.Sh SYNOPSIS
28.Lb libtls libssl libcrypto
28.In tls.h 29.In tls.h
29.Ft void 30.Ft void
30.Fn tls_config_verify "struct tls_config *config" 31.Fn tls_config_verify "struct tls_config *config"
diff --git a/src/lib/libtls/man/tls_conn_version.3 b/src/lib/libtls/man/tls_conn_version.3
index 8fb30624d7..3a386cf11f 100644
--- a/src/lib/libtls/man/tls_conn_version.3
+++ b/src/lib/libtls/man/tls_conn_version.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_conn_version.3,v 1.11 2024/12/10 08:42:12 tb Exp $ 1.\" $OpenBSD: tls_conn_version.3,v 1.12 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3.\" Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4.\" Copyright (c) 2016, 2018 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2016, 2018 Joel Sing <jsing@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: December 10 2024 $ 18.Dd $Mdocdate: July 7 2025 $
19.Dt TLS_CONN_VERSION 3 19.Dt TLS_CONN_VERSION 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -36,6 +36,7 @@
36.Nm tls_peer_cert_notafter 36.Nm tls_peer_cert_notafter
37.Nd inspect an established TLS connection 37.Nd inspect an established TLS connection
38.Sh SYNOPSIS 38.Sh SYNOPSIS
39.Lb libtls libssl libcrypto
39.In tls.h 40.In tls.h
40.Ft const char * 41.Ft const char *
41.Fn tls_conn_version "struct tls *ctx" 42.Fn tls_conn_version "struct tls *ctx"
diff --git a/src/lib/libtls/man/tls_connect.3 b/src/lib/libtls/man/tls_connect.3
index 4c4f01c256..95a18864b2 100644
--- a/src/lib/libtls/man/tls_connect.3
+++ b/src/lib/libtls/man/tls_connect.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_connect.3,v 1.4 2018/07/09 19:51:18 tb Exp $ 1.\" $OpenBSD: tls_connect.3,v 1.5 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2014, 2015 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2014, 2015 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: July 9 2018 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_CONNECT 3 20.Dt TLS_CONNECT 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -27,6 +27,7 @@
27.Nm tls_connect_cbs 27.Nm tls_connect_cbs
28.Nd instruct a TLS client to establish a connection 28.Nd instruct a TLS client to establish a connection
29.Sh SYNOPSIS 29.Sh SYNOPSIS
30.Lb libtls libssl libcrypto
30.In tls.h 31.In tls.h
31.Ft int 32.Ft int
32.Fo tls_connect 33.Fo tls_connect
diff --git a/src/lib/libtls/man/tls_init.3 b/src/lib/libtls/man/tls_init.3
index 557998107c..69879c04c7 100644
--- a/src/lib/libtls/man/tls_init.3
+++ b/src/lib/libtls/man/tls_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_init.3,v 1.13 2018/07/09 19:47:20 tb Exp $ 1.\" $OpenBSD: tls_init.3,v 1.14 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2016 Joel Sing <jsing@openbsd.org> 4.\" Copyright (c) 2016 Joel Sing <jsing@openbsd.org>
@@ -16,7 +16,7 @@
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\" 18.\"
19.Dd $Mdocdate: July 9 2018 $ 19.Dd $Mdocdate: July 7 2025 $
20.Dt TLS_INIT 3 20.Dt TLS_INIT 3
21.Os 21.Os
22.Sh NAME 22.Sh NAME
@@ -26,6 +26,7 @@
26.Nm tls_config_error 26.Nm tls_config_error
27.Nd initialize TLS client and server API 27.Nd initialize TLS client and server API
28.Sh SYNOPSIS 28.Sh SYNOPSIS
29.Lb libtls libssl libcrypto
29.In tls.h 30.In tls.h
30.Ft int 31.Ft int
31.Fn tls_init void 32.Fn tls_init void
diff --git a/src/lib/libtls/man/tls_load_file.3 b/src/lib/libtls/man/tls_load_file.3
index cf33b575ef..33f486d530 100644
--- a/src/lib/libtls/man/tls_load_file.3
+++ b/src/lib/libtls/man/tls_load_file.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_load_file.3,v 1.14 2022/01/01 02:18:28 jsg Exp $ 1.\" $OpenBSD: tls_load_file.3,v 1.15 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> 4.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -17,7 +17,7 @@
17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19.\" 19.\"
20.Dd $Mdocdate: January 1 2022 $ 20.Dd $Mdocdate: July 7 2025 $
21.Dt TLS_LOAD_FILE 3 21.Dt TLS_LOAD_FILE 3
22.Os 22.Os
23.Sh NAME 23.Sh NAME
@@ -49,6 +49,7 @@
49.Nm tls_default_ca_cert_file 49.Nm tls_default_ca_cert_file
50.Nd TLS certificate and key configuration 50.Nd TLS certificate and key configuration
51.Sh SYNOPSIS 51.Sh SYNOPSIS
52.Lb libtls libssl libcrypto
52.In tls.h 53.In tls.h
53.Ft uint8_t * 54.Ft uint8_t *
54.Fo tls_load_file 55.Fo tls_load_file
diff --git a/src/lib/libtls/man/tls_ocsp_process_response.3 b/src/lib/libtls/man/tls_ocsp_process_response.3
index 6e3aa4aecc..e7b57a6827 100644
--- a/src/lib/libtls/man/tls_ocsp_process_response.3
+++ b/src/lib/libtls/man/tls_ocsp_process_response.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_ocsp_process_response.3,v 1.6 2018/07/24 02:01:34 tb Exp $ 1.\" $OpenBSD: tls_ocsp_process_response.3,v 1.7 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org> 3.\" Copyright (c) 2016 Bob Beck <beck@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: July 24 2018 $ 17.Dd $Mdocdate: July 7 2025 $
18.Dt TLS_OCSP_PROCESS_RESPONSE 3 18.Dt TLS_OCSP_PROCESS_RESPONSE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -29,6 +29,7 @@
29.Nm tls_peer_ocsp_next_update 29.Nm tls_peer_ocsp_next_update
30.Nd inspect an OCSP response 30.Nd inspect an OCSP response
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libtls libssl libcrypto
32.In tls.h 33.In tls.h
33.Ft int 34.Ft int
34.Fo tls_ocsp_process_response 35.Fo tls_ocsp_process_response
diff --git a/src/lib/libtls/man/tls_read.3 b/src/lib/libtls/man/tls_read.3
index f9d949eef5..f72e63cf63 100644
--- a/src/lib/libtls/man/tls_read.3
+++ b/src/lib/libtls/man/tls_read.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_read.3,v 1.8 2023/09/18 17:25:15 schwarze Exp $ 1.\" $OpenBSD: tls_read.3,v 1.9 2025/07/07 10:54:00 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014, 2015 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014, 2015 Ted Unangst <tedu@openbsd.org>
4.\" Copyright (c) 2015 Doug Hogan <doug@openbsd.org> 4.\" Copyright (c) 2015 Doug Hogan <doug@openbsd.org>
@@ -18,7 +18,7 @@
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\" 20.\"
21.Dd $Mdocdate: September 18 2023 $ 21.Dd $Mdocdate: July 7 2025 $
22.Dt TLS_READ 3 22.Dt TLS_READ 3
23.Os 23.Os
24.Sh NAME 24.Sh NAME
@@ -29,6 +29,7 @@
29.Nm tls_close 29.Nm tls_close
30.Nd use a TLS connection 30.Nd use a TLS connection
31.Sh SYNOPSIS 31.Sh SYNOPSIS
32.Lb libtls libssl libcrypto
32.In tls.h 33.In tls.h
33.Ft ssize_t 34.Ft ssize_t
34.Fo tls_read 35.Fo tls_read
diff --git a/src/lib/libtls/shlib_version b/src/lib/libtls/shlib_version
index 3040494c17..715847ed94 100644
--- a/src/lib/libtls/shlib_version
+++ b/src/lib/libtls/shlib_version
@@ -1,2 +1,2 @@
1major=32 1major=33
2minor=1 2minor=2
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c
index 41bb06d857..02ff337b1e 100644
--- a/src/lib/libtls/tls.c
+++ b/src/lib/libtls/tls.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls.c,v 1.104 2024/04/08 20:47:32 tb Exp $ */ 1/* $OpenBSD: tls.c,v 1.105 2026/04/16 07:28:00 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -686,7 +686,7 @@ tls_configure_ssl_verify(struct tls *ctx, SSL_CTX *ssl_ctx, int verify)
686 if (xi->crl == NULL) 686 if (xi->crl == NULL)
687 continue; 687 continue;
688 if (!X509_STORE_add_crl(store, xi->crl)) { 688 if (!X509_STORE_add_crl(store, xi->crl)) {
689 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 689 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
690 "failed to add crl"); 690 "failed to add crl");
691 goto err; 691 goto err;
692 } 692 }
diff --git a/src/lib/libtls/tls_client.c b/src/lib/libtls/tls_client.c
index 97e1d40210..7de9927b94 100644
--- a/src/lib/libtls/tls_client.c
+++ b/src/lib/libtls/tls_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_client.c,v 1.51 2024/03/26 08:54:48 joshua Exp $ */ 1/* $OpenBSD: tls_client.c,v 1.52 2026/04/16 07:28:00 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -115,7 +115,7 @@ tls_connect_servername(struct tls *ctx, const char *host, const char *port,
115 hints.ai_family = AF_UNSPEC; 115 hints.ai_family = AF_UNSPEC;
116 hints.ai_flags = AI_ADDRCONFIG; 116 hints.ai_flags = AI_ADDRCONFIG;
117 if ((s = getaddrinfo(h, p, &hints, &res0)) != 0) { 117 if ((s = getaddrinfo(h, p, &hints, &res0)) != 0) {
118 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 118 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
119 "%s", gai_strerror(s)); 119 "%s", gai_strerror(s));
120 goto err; 120 goto err;
121 } 121 }
diff --git a/src/lib/libtls/tls_config.c b/src/lib/libtls/tls_config.c
index 22fa8455a1..d35c5065c5 100644
--- a/src/lib/libtls/tls_config.c
+++ b/src/lib/libtls/tls_config.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_config.c,v 1.71 2024/08/02 15:00:01 tb Exp $ */ 1/* $OpenBSD: tls_config.c,v 1.73 2026/04/16 07:33:11 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -49,7 +49,7 @@ tls_config_load_file(struct tls_error *error, const char *filetype,
49 *buf = NULL; 49 *buf = NULL;
50 *len = 0; 50 *len = 0;
51 51
52 if ((fd = open(filename, O_RDONLY)) == -1) { 52 if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) == -1) {
53 tls_error_set(error, TLS_ERROR_UNKNOWN, 53 tls_error_set(error, TLS_ERROR_UNKNOWN,
54 "failed to open %s file '%s'", 54 "failed to open %s file '%s'",
55 filetype, filename); 55 filetype, filename);
@@ -65,7 +65,7 @@ tls_config_load_file(struct tls_error *error, const char *filetype,
65 goto err; 65 goto err;
66 *len = (size_t)st.st_size; 66 *len = (size_t)st.st_size;
67 if ((*buf = malloc(*len)) == NULL) { 67 if ((*buf = malloc(*len)) == NULL) {
68 tls_error_set(error, TLS_ERROR_UNKNOWN, 68 tls_error_setx(error, TLS_ERROR_OUT_OF_MEMORY,
69 "failed to allocate buffer for %s file", 69 "failed to allocate buffer for %s file",
70 filetype); 70 filetype);
71 goto err; 71 goto err;
diff --git a/src/lib/libtls/tls_conninfo.c b/src/lib/libtls/tls_conninfo.c
index 8fb56c92b7..5707ec6703 100644
--- a/src/lib/libtls/tls_conninfo.c
+++ b/src/lib/libtls/tls_conninfo.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_conninfo.c,v 1.28 2024/12/10 08:40:30 tb Exp $ */ 1/* $OpenBSD: tls_conninfo.c,v 1.29 2026/03/28 11:33:33 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
@@ -89,7 +89,7 @@ tls_get_peer_cert_hash(struct tls *ctx, char **hash)
89static int 89static int
90tls_get_peer_cert_issuer(struct tls *ctx, char **issuer) 90tls_get_peer_cert_issuer(struct tls *ctx, char **issuer)
91{ 91{
92 X509_NAME *name = NULL; 92 const X509_NAME *name = NULL;
93 93
94 *issuer = NULL; 94 *issuer = NULL;
95 if (ctx->ssl_peer_cert == NULL) 95 if (ctx->ssl_peer_cert == NULL)
@@ -105,7 +105,7 @@ tls_get_peer_cert_issuer(struct tls *ctx, char **issuer)
105static int 105static int
106tls_get_peer_cert_subject(struct tls *ctx, char **subject) 106tls_get_peer_cert_subject(struct tls *ctx, char **subject)
107{ 107{
108 X509_NAME *name = NULL; 108 const X509_NAME *name = NULL;
109 109
110 *subject = NULL; 110 *subject = NULL;
111 if (ctx->ssl_peer_cert == NULL) 111 if (ctx->ssl_peer_cert == NULL)
diff --git a/src/lib/libtls/tls_keypair.c b/src/lib/libtls/tls_keypair.c
index ffda91df8e..b485a21ea1 100644
--- a/src/lib/libtls/tls_keypair.c
+++ b/src/lib/libtls/tls_keypair.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_keypair.c,v 1.9 2024/03/26 06:24:52 joshua Exp $ */ 1/* $OpenBSD: tls_keypair.c,v 1.13 2026/04/20 04:35:00 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -15,6 +15,8 @@
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */ 16 */
17 17
18#include <limits.h>
19
18#include <openssl/bio.h> 20#include <openssl/bio.h>
19#include <openssl/err.h> 21#include <openssl/err.h>
20#include <openssl/pem.h> 22#include <openssl/pem.h>
@@ -144,13 +146,18 @@ tls_keypair_load_cert(struct tls_keypair *keypair, struct tls_error *error,
144 *cert = NULL; 146 *cert = NULL;
145 147
146 if (keypair->cert_mem == NULL) { 148 if (keypair->cert_mem == NULL) {
147 tls_error_set(error, TLS_ERROR_UNKNOWN, 149 tls_error_setx(error, TLS_ERROR_UNKNOWN,
148 "keypair has no certificate"); 150 "keypair has no certificate");
149 goto err; 151 goto err;
150 } 152 }
153 if (keypair->cert_len > INT_MAX) {
154 tls_error_setx(error, TLS_ERROR_INVALID_ARGUMENT,
155 "certificate too long");
156 goto err;
157 }
151 if ((cert_bio = BIO_new_mem_buf(keypair->cert_mem, 158 if ((cert_bio = BIO_new_mem_buf(keypair->cert_mem,
152 keypair->cert_len)) == NULL) { 159 keypair->cert_len)) == NULL) {
153 tls_error_set(error, TLS_ERROR_UNKNOWN, 160 tls_error_setx(error, TLS_ERROR_UNKNOWN,
154 "failed to create certificate bio"); 161 "failed to create certificate bio");
155 goto err; 162 goto err;
156 } 163 }
@@ -158,7 +165,7 @@ tls_keypair_load_cert(struct tls_keypair *keypair, struct tls_error *error,
158 NULL)) == NULL) { 165 NULL)) == NULL) {
159 if ((ssl_err = ERR_peek_error()) != 0) 166 if ((ssl_err = ERR_peek_error()) != 0)
160 errstr = ERR_error_string(ssl_err, NULL); 167 errstr = ERR_error_string(ssl_err, NULL);
161 tls_error_set(error, TLS_ERROR_UNKNOWN, 168 tls_error_setx(error, TLS_ERROR_UNKNOWN,
162 "failed to load certificate: %s", errstr); 169 "failed to load certificate: %s", errstr);
163 goto err; 170 goto err;
164 } 171 }
diff --git a/src/lib/libtls/tls_ocsp.c b/src/lib/libtls/tls_ocsp.c
index bfd06e3c6a..b8d855c4c8 100644
--- a/src/lib/libtls/tls_ocsp.c
+++ b/src/lib/libtls/tls_ocsp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_ocsp.c,v 1.26 2024/03/26 06:24:52 joshua Exp $ */ 1/* $OpenBSD: tls_ocsp.c,v 1.29 2026/04/16 07:35:25 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Marko Kreen <markokr@gmail.com> 3 * Copyright (c) 2015 Marko Kreen <markokr@gmail.com>
4 * Copyright (c) 2016 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2016 Bob Beck <beck@openbsd.org>
@@ -85,7 +85,7 @@ tls_ocsp_fill_info(struct tls *ctx, int response_status, int cert_status,
85 ctx->ocsp->ocsp_result = NULL; 85 ctx->ocsp->ocsp_result = NULL;
86 86
87 if ((info = calloc(1, sizeof (struct tls_ocsp_result))) == NULL) { 87 if ((info = calloc(1, sizeof (struct tls_ocsp_result))) == NULL) {
88 tls_set_error(ctx, TLS_ERROR_OUT_OF_MEMORY, "out of memory"); 88 tls_set_errorx(ctx, TLS_ERROR_OUT_OF_MEMORY, "out of memory");
89 return -1; 89 return -1;
90 } 90 }
91 info->response_status = response_status; 91 info->response_status = response_status;
@@ -102,19 +102,19 @@ tls_ocsp_fill_info(struct tls *ctx, int response_status, int cert_status,
102 info->revocation_time = info->this_update = info->next_update = -1; 102 info->revocation_time = info->this_update = info->next_update = -1;
103 if (revtime != NULL && 103 if (revtime != NULL &&
104 tls_ocsp_asn1_parse_time(ctx, revtime, &info->revocation_time) != 0) { 104 tls_ocsp_asn1_parse_time(ctx, revtime, &info->revocation_time) != 0) {
105 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 105 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
106 "unable to parse revocation time in OCSP reply"); 106 "unable to parse revocation time in OCSP reply");
107 goto err; 107 goto err;
108 } 108 }
109 if (thisupd != NULL && 109 if (thisupd != NULL &&
110 tls_ocsp_asn1_parse_time(ctx, thisupd, &info->this_update) != 0) { 110 tls_ocsp_asn1_parse_time(ctx, thisupd, &info->this_update) != 0) {
111 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 111 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
112 "unable to parse this update time in OCSP reply"); 112 "unable to parse this update time in OCSP reply");
113 goto err; 113 goto err;
114 } 114 }
115 if (nextupd != NULL && 115 if (nextupd != NULL &&
116 tls_ocsp_asn1_parse_time(ctx, nextupd, &info->next_update) != 0) { 116 tls_ocsp_asn1_parse_time(ctx, nextupd, &info->next_update) != 0) {
117 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 117 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
118 "unable to parse next update time in OCSP reply"); 118 "unable to parse next update time in OCSP reply");
119 goto err; 119 goto err;
120 } 120 }
@@ -130,7 +130,7 @@ static OCSP_CERTID *
130tls_ocsp_get_certid(X509 *main_cert, STACK_OF(X509) *extra_certs, 130tls_ocsp_get_certid(X509 *main_cert, STACK_OF(X509) *extra_certs,
131 SSL_CTX *ssl_ctx) 131 SSL_CTX *ssl_ctx)
132{ 132{
133 X509_NAME *issuer_name; 133 const X509_NAME *issuer_name;
134 X509 *issuer; 134 X509 *issuer;
135 X509_STORE_CTX *storectx = NULL; 135 X509_STORE_CTX *storectx = NULL;
136 X509_OBJECT *obj = NULL; 136 X509_OBJECT *obj = NULL;
@@ -141,7 +141,8 @@ tls_ocsp_get_certid(X509 *main_cert, STACK_OF(X509) *extra_certs,
141 goto out; 141 goto out;
142 142
143 if (extra_certs != NULL) { 143 if (extra_certs != NULL) {
144 issuer = X509_find_by_subject(extra_certs, issuer_name); 144 issuer = X509_find_by_subject(extra_certs,
145 (X509_NAME *)issuer_name);
145 if (issuer != NULL) { 146 if (issuer != NULL) {
146 cid = OCSP_cert_to_id(NULL, main_cert, issuer); 147 cid = OCSP_cert_to_id(NULL, main_cert, issuer);
147 goto out; 148 goto out;
@@ -155,7 +156,7 @@ tls_ocsp_get_certid(X509 *main_cert, STACK_OF(X509) *extra_certs,
155 if (X509_STORE_CTX_init(storectx, store, main_cert, extra_certs) != 1) 156 if (X509_STORE_CTX_init(storectx, store, main_cert, extra_certs) != 1)
156 goto out; 157 goto out;
157 if ((obj = X509_STORE_CTX_get_obj_by_subject(storectx, X509_LU_X509, 158 if ((obj = X509_STORE_CTX_get_obj_by_subject(storectx, X509_LU_X509,
158 issuer_name)) == NULL) 159 (X509_NAME *)issuer_name)) == NULL)
159 goto out; 160 goto out;
160 161
161 cid = OCSP_cert_to_id(NULL, main_cert, X509_OBJECT_get0_X509(obj)); 162 cid = OCSP_cert_to_id(NULL, main_cert, X509_OBJECT_get0_X509(obj));
@@ -304,7 +305,7 @@ tls_ocsp_process_response_internal(struct tls *ctx, const unsigned char *respons
304 if (resp == NULL) { 305 if (resp == NULL) {
305 tls_ocsp_free(ctx->ocsp); 306 tls_ocsp_free(ctx->ocsp);
306 ctx->ocsp = NULL; 307 ctx->ocsp = NULL;
307 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 308 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
308 "unable to parse OCSP response"); 309 "unable to parse OCSP response");
309 return -1; 310 return -1;
310 } 311 }
diff --git a/src/lib/libtls/tls_server.c b/src/lib/libtls/tls_server.c
index a94b4221ed..570020d6a2 100644
--- a/src/lib/libtls/tls_server.c
+++ b/src/lib/libtls/tls_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_server.c,v 1.51 2024/03/26 08:54:48 joshua Exp $ */ 1/* $OpenBSD: tls_server.c,v 1.53 2026/04/16 07:28:00 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -75,7 +75,7 @@ tls_server_alpn_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen,
75 OPENSSL_NPN_NEGOTIATED) 75 OPENSSL_NPN_NEGOTIATED)
76 return (SSL_TLSEXT_ERR_OK); 76 return (SSL_TLSEXT_ERR_OK);
77 77
78 return (SSL_TLSEXT_ERR_NOACK); 78 return (SSL_TLSEXT_ERR_ALERT_FATAL);
79} 79}
80 80
81static int 81static int
@@ -242,12 +242,12 @@ tls_configure_server_ssl(struct tls *ctx, SSL_CTX **ssl_ctx,
242 242
243 if (SSL_CTX_set_tlsext_servername_callback(*ssl_ctx, 243 if (SSL_CTX_set_tlsext_servername_callback(*ssl_ctx,
244 tls_servername_cb) != 1) { 244 tls_servername_cb) != 1) {
245 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 245 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
246 "failed to set servername callback"); 246 "failed to set servername callback");
247 goto err; 247 goto err;
248 } 248 }
249 if (SSL_CTX_set_tlsext_servername_arg(*ssl_ctx, ctx) != 1) { 249 if (SSL_CTX_set_tlsext_servername_arg(*ssl_ctx, ctx) != 1) {
250 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 250 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
251 "failed to set servername callback arg"); 251 "failed to set servername callback arg");
252 goto err; 252 goto err;
253 } 253 }
@@ -298,7 +298,7 @@ tls_configure_server_ssl(struct tls *ctx, SSL_CTX **ssl_ctx,
298 SSL_CTX_clear_options(*ssl_ctx, SSL_OP_NO_TICKET); 298 SSL_CTX_clear_options(*ssl_ctx, SSL_OP_NO_TICKET);
299 if (!SSL_CTX_set_tlsext_ticket_key_cb(*ssl_ctx, 299 if (!SSL_CTX_set_tlsext_ticket_key_cb(*ssl_ctx,
300 tls_server_ticket_cb)) { 300 tls_server_ticket_cb)) {
301 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 301 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
302 "failed to set the TLS ticket callback"); 302 "failed to set the TLS ticket callback");
303 goto err; 303 goto err;
304 } 304 }
@@ -306,7 +306,7 @@ tls_configure_server_ssl(struct tls *ctx, SSL_CTX **ssl_ctx,
306 306
307 if (SSL_CTX_set_session_id_context(*ssl_ctx, ctx->config->session_id, 307 if (SSL_CTX_set_session_id_context(*ssl_ctx, ctx->config->session_id,
308 sizeof(ctx->config->session_id)) != 1) { 308 sizeof(ctx->config->session_id)) != 1) {
309 tls_set_error(ctx, TLS_ERROR_UNKNOWN, 309 tls_set_errorx(ctx, TLS_ERROR_UNKNOWN,
310 "failed to set session id context"); 310 "failed to set session id context");
311 goto err; 311 goto err;
312 } 312 }
diff --git a/src/lib/libtls/tls_signer.c b/src/lib/libtls/tls_signer.c
index 2573803ec1..2d6635460e 100644
--- a/src/lib/libtls/tls_signer.c
+++ b/src/lib/libtls/tls_signer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_signer.c,v 1.13 2024/06/11 16:35:24 op Exp $ */ 1/* $OpenBSD: tls_signer.c,v 1.15 2026/04/16 07:35:25 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2021 Eric Faurot <eric@openbsd.org> 3 * Copyright (c) 2021 Eric Faurot <eric@openbsd.org>
4 * 4 *
@@ -99,6 +99,11 @@ tls_signer_add_keypair_mem(struct tls_signer *signer, const uint8_t *cert,
99 char *hash = NULL; 99 char *hash = NULL;
100 100
101 /* Compute certificate hash */ 101 /* Compute certificate hash */
102 if (cert_len > INT_MAX) {
103 tls_error_setx(&signer->error, TLS_ERROR_INVALID_ARGUMENT,
104 "certificate too long");
105 goto err;
106 }
102 if ((bio = BIO_new_mem_buf(cert, cert_len)) == NULL) { 107 if ((bio = BIO_new_mem_buf(cert, cert_len)) == NULL) {
103 tls_error_setx(&signer->error, TLS_ERROR_UNKNOWN, 108 tls_error_setx(&signer->error, TLS_ERROR_UNKNOWN,
104 "failed to create certificate bio"); 109 "failed to create certificate bio");
@@ -124,6 +129,11 @@ tls_signer_add_keypair_mem(struct tls_signer *signer, const uint8_t *cert,
124 bio = NULL; 129 bio = NULL;
125 130
126 /* Read private key */ 131 /* Read private key */
132 if (key_len > INT_MAX) {
133 tls_error_setx(&signer->error, TLS_ERROR_INVALID_ARGUMENT,
134 "private key too long");
135 goto err;
136 }
127 if ((bio = BIO_new_mem_buf(key, key_len)) == NULL) { 137 if ((bio = BIO_new_mem_buf(key, key_len)) == NULL) {
128 tls_error_setx(&signer->error, TLS_ERROR_UNKNOWN, 138 tls_error_setx(&signer->error, TLS_ERROR_UNKNOWN,
129 "failed to create key bio"); 139 "failed to create key bio");
@@ -137,7 +147,7 @@ tls_signer_add_keypair_mem(struct tls_signer *signer, const uint8_t *cert,
137 } 147 }
138 148
139 if ((skey = calloc(1, sizeof(*skey))) == NULL) { 149 if ((skey = calloc(1, sizeof(*skey))) == NULL) {
140 tls_error_set(&signer->error, TLS_ERROR_OUT_OF_MEMORY, 150 tls_error_setx(&signer->error, TLS_ERROR_OUT_OF_MEMORY,
141 "out of memory"); 151 "out of memory");
142 goto err; 152 goto err;
143 } 153 }
@@ -223,7 +233,7 @@ tls_sign_rsa(struct tls_signer *signer, struct tls_signer_key *skey,
223 return (-1); 233 return (-1);
224 } 234 }
225 if ((signature = calloc(1, rsa_size)) == NULL) { 235 if ((signature = calloc(1, rsa_size)) == NULL) {
226 tls_error_set(&signer->error, TLS_ERROR_OUT_OF_MEMORY, 236 tls_error_setx(&signer->error, TLS_ERROR_OUT_OF_MEMORY,
227 "out of memory"); 237 "out of memory");
228 return (-1); 238 return (-1);
229 } 239 }
@@ -271,7 +281,7 @@ tls_sign_ecdsa(struct tls_signer *signer, struct tls_signer_key *skey,
271 return (-1); 281 return (-1);
272 } 282 }
273 if ((signature = calloc(1, signature_len)) == NULL) { 283 if ((signature = calloc(1, signature_len)) == NULL) {
274 tls_error_set(&signer->error, TLS_ERROR_OUT_OF_MEMORY, 284 tls_error_setx(&signer->error, TLS_ERROR_OUT_OF_MEMORY,
275 "out of memory"); 285 "out of memory");
276 return (-1); 286 return (-1);
277 } 287 }
diff --git a/src/lib/libtls/tls_util.c b/src/lib/libtls/tls_util.c
index b276d2cfa7..d93efb830d 100644
--- a/src/lib/libtls/tls_util.c
+++ b/src/lib/libtls/tls_util.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_util.c,v 1.16 2023/05/14 07:26:25 op Exp $ */ 1/* $OpenBSD: tls_util.c,v 1.17 2026/03/10 05:26:04 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 4 * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
@@ -162,7 +162,7 @@ tls_load_file(const char *name, size_t *len, char *password)
162 162
163 *len = 0; 163 *len = 0;
164 164
165 if ((fd = open(name, O_RDONLY)) == -1) 165 if ((fd = open(name, O_RDONLY|O_CLOEXEC)) == -1)
166 return (NULL); 166 return (NULL);
167 167
168 /* Just load the file into memory without decryption */ 168 /* Just load the file into memory without decryption */
diff --git a/src/lib/libtls/tls_verify.c b/src/lib/libtls/tls_verify.c
index 2935278383..de95ab8117 100644
--- a/src/lib/libtls/tls_verify.c
+++ b/src/lib/libtls/tls_verify.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_verify.c,v 1.32 2024/12/10 08:40:30 tb Exp $ */ 1/* $OpenBSD: tls_verify.c,v 1.33 2026/03/28 11:33:33 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> 3 * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org>
4 * 4 *
@@ -214,10 +214,10 @@ tls_get_common_name_internal(X509 *cert, char **out_common_name,
214 unsigned int *out_tlserr, const char **out_errstr) 214 unsigned int *out_tlserr, const char **out_errstr)
215{ 215{
216 unsigned char *utf8_bytes = NULL; 216 unsigned char *utf8_bytes = NULL;
217 X509_NAME *subject_name; 217 const X509_NAME *subject_name;
218 char *common_name = NULL; 218 char *common_name = NULL;
219 int common_name_len; 219 int common_name_len;
220 ASN1_STRING *data; 220 const ASN1_STRING *data;
221 int lastpos = -1; 221 int lastpos = -1;
222 int rv = -1; 222 int rv = -1;
223 223