openssl
एक अंधेरे कला का एक सा है।
सबसे पहले जिस पृष्ठ पर आपने संदर्भित किया है, उसमें HTML-वापसी का मूल्य खराब है। यहां बताया गया है मानव पेज वास्तव में कहते है:
RETURN VALUES
The following return values can occur:
0 The shutdown is not yet finished. Call SSL_shutdown() for a second
time, if a bidirectional shutdown shall be performed. The output
of SSL_get_error(3) may be misleading, as an erroneous
SSL_ERROR_SYSCALL may be flagged even though no error occurred.
1 The shutdown was successfully completed. The "close notify" alert
was sent and the peer's "close notify" alert was received.
-1 The shutdown was not successful because a fatal error occurred
either at the protocol level or a connection failure occurred. It
can also occur if action is need to continue the operation for non-
blocking BIOs. Call SSL_get_error(3) with the return value ret to
find out the reason.
आप BIOS को अवरुद्ध किया है, तो चीजें अपेक्षाकृत आसान है। पहली कॉल पर 0 का मतलब है कि यदि आप एक द्विपक्षीय शट डाउन चाहते हैं तो आपको SSL_shutdown
पर कॉल करने की आवश्यकता है। ए 1 का मतलब है कि आप कर चुके हैं। ए -1 का मतलब एक त्रुटि है। दूसरी कॉल पर (जो आप केवल 0 करते हैं यदि आप 0 वापस प्राप्त करते हैं), तो एक बिडरेक्शनल शटडाउन शुरू किया जाता है। तर्क बताता है कि आप 0 बार फिर से नहीं प्राप्त कर सकते हैं (क्योंकि यह एक अवरुद्ध बीआईओ है और पहला कदम पूरा कर लेगा)। ए -1 एक त्रुटि इंगित करता है, और एक 1 पूरा होने का संकेत देता है।
आप गैर-अवरुद्ध BIOS है, तो एक ही लागू होता है, सच है कि आप पूरे SSL_ERROR_WANT_READ
और SSL_ERROR_WANT_WRITE
बेसिरपैर की बात के माध्यम से जाने की जरूरत है, यानी .:
If the underlying BIO is non-blocking, SSL_shutdown() will also return
when the underlying BIO could not satisfy the needs of SSL_shutdown()
to continue the handshake. In this case a call to SSL_get_error() with
the return value of SSL_shutdown() will yield SSL_ERROR_WANT_READ or
SSL_ERROR_WANT_WRITE. The calling process then must repeat the call
after taking appropriate action to satisfy the needs of SSL_shutdown().
The action depends on the underlying BIO. When using a non-blocking
socket, nothing is to be done, but select() can be used to check for
the required condition. When using a buffering BIO, like a BIO pair,
data must be written into or retrieved out of the BIO before being able
to continue.
तो तुम पुनरावृत्ति के दो स्तर है को बचाने के लिए। SSL_shutdown
को 'पहला' समय पर कॉल करें, लेकिन SSL_ERROR_WANT_READ
या SSL_ERROR_WANT_WRITE
को सामान्य तरीके से select()
लूप के आसपास जाने के बाद दोहराएं, और केवल 'पहले' SSL_shutdown
को गिनें, यदि आपको गैर SSL_ERROR_WANT_
त्रुटि कोड मिलता है (इस मामले में असफल), या आपको 0
या 1
वापसी मिलती है। अगर आपको 1
रिटर्न मिलता है, तो आपने किया है। अगर आपको 0
रिटर्न मिलता है, और आप एक द्विपक्षीय शट डाउन चाहते हैं, तो आपको दूसरी कॉल करना होगा, जिस पर आपको SSL_ERROR_WANT_READ
या SSL_ERROR_WANT_WRITE
और फिर से प्रयास करने की आवश्यकता होगी; जो 1
वापस नहीं करना चाहिए, लेकिन 0 या एक त्रुटि लौटा सकता है।
आसान नहीं है।
धन्यवाद! बहुत सराहना की मदद। – cmidi