From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id AD9CC40D3B for ; Sun, 13 Jul 2025 19:25:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 5D3C868E320; Sun, 13 Jul 2025 22:25:30 +0300 (EEST) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 8FFA5687DAF for ; Sun, 13 Jul 2025 22:25:22 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 0BA9C28190F33; Sun, 13 Jul 2025 21:25:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1752434722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FdtFieL4cgLQQw7OxCUMi4Eq7Ht2jkNwWYsYFJ6GWdE=; b=VYVmd8LZoVMivVXNktHVpkimFToz84DoXvwozDCHB2zNACShOcNlD/MxgtwOQsFDN3gH53 Bj8eOQ6gFNvNJdfFzy8Xp+QLZWCCutgFoerII4WDAtvTzDV33kWpQxnBlBeBENqmL7P6PC uhW2ETVVR1Yksu9z089yZuHGNhFjOaUFtzvM2d4+kwKRdY1Ry4S7Tr3K8Ji7FDomTOuZ9u tpcWTT9kNvbPfu6WUNWbVlUIjAiMposSpK+aEXF5u7hZVa4lzoaSLhPstgPN4llqb+Y67f rTbn/4UrLpaCtwOquMydMELkueeWULJoUVpd2Pgca5xj8sF4Fc8Leu32iKgBQg== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Jul 2025 21:24:36 +0200 Message-ID: <20250713192512.928390-2-timo@rothenpieler.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250713192512.928390-1-timo@rothenpieler.org> References: <20250713192512.928390-1-timo@rothenpieler.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/14] avformat/tls_openssl: force dtls handshake to be blocking X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Timo Rothenpieler Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: There is no sensible way to handle this otherwise anyway, one just has to loop over this function until it succeeds. --- libavformat/tls_openssl.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index f6826222f9..54213c4090 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -685,27 +685,33 @@ static int openssl_dtls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx) static int dtls_handshake(URLContext *h) { - int ret = 0, r0, r1; + int ret = 1, r0, r1; TLSContext *p = h->priv_data; + int was_nonblock = h->flags & AVIO_FLAG_NONBLOCK; + h->flags &= ~AVIO_FLAG_NONBLOCK; + r0 = SSL_do_handshake(p->ssl); - r1 = SSL_get_error(p->ssl, r0); if (r0 <= 0) { + r1 = SSL_get_error(p->ssl, r0); + if (r1 != SSL_ERROR_WANT_READ && r1 != SSL_ERROR_WANT_WRITE && r1 != SSL_ERROR_ZERO_RETURN) { - av_log(p, AV_LOG_ERROR, "TLS: Read failed, r0=%d, r1=%d %s\n", r0, r1, openssl_get_error(p)); - ret = AVERROR(EIO); + av_log(p, AV_LOG_ERROR, "Handshake failed, r0=%d, r1=%d\n", r0, r1); + ret = print_ssl_error(h, r0); goto end; } } else { - av_log(p, AV_LOG_TRACE, "TLS: Read %d bytes, r0=%d, r1=%d\n", r0, r0, r1); + av_log(p, AV_LOG_TRACE, "Handshake success, r0=%d\n", r0); } - /* Check whether the DTLS is completed. */ if (SSL_is_init_finished(p->ssl) != 1) goto end; + ret = 0; p->tls_shared.state = DTLS_STATE_FINISHED; end: + if (was_nonblock) + h->flags |= AVIO_FLAG_NONBLOCK; return ret; } -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".