@@ -388,10 +388,14 @@ osslerror_detailed_message(int argc, VALUE *argv, VALUE self)
388388 * call-seq:
389389 * OpenSSL.errors -> [String...]
390390 *
391- * See any remaining errors held in queue.
391+ * Returns any remaining errors held in the OpenSSL thread-local error queue
392+ * and clears the queue. This should normally return an empty array.
392393 *
393- * Any errors you see here are probably due to a bug in Ruby's OpenSSL
394- * implementation.
394+ * This is intended for debugging Ruby/OpenSSL. If you see any errors here,
395+ * it likely indicates a bug in the extension. Please file an issue at
396+ * https://github.com/ruby/openssl.
397+ *
398+ * For debugging your program, OpenSSL.debug= may be useful.
395399 */
396400static VALUE
397401ossl_get_errors (VALUE _ )
@@ -415,6 +419,8 @@ VALUE dOSSL;
415419/*
416420 * call-seq:
417421 * OpenSSL.debug -> true | false
422+ *
423+ * Returns whether Ruby/OpenSSL's debug mode is currently enabled.
418424 */
419425static VALUE
420426ossl_debug_get (VALUE self )
@@ -424,7 +430,7 @@ ossl_debug_get(VALUE self)
424430
425431/*
426432 * call-seq:
427- * OpenSSL.debug = boolean -> boolean
433+ * OpenSSL.debug = boolean
428434 *
429435 * Turns on or off debug mode. With debug mode, all errors added to the OpenSSL
430436 * error queue will be printed to stderr.
@@ -440,6 +446,8 @@ ossl_debug_set(VALUE self, VALUE val)
440446/*
441447 * call-seq:
442448 * OpenSSL.fips_mode -> true | false
449+ *
450+ * Returns whether the FIPS mode is currently enabled.
443451 */
444452static VALUE
445453ossl_fips_mode_get (VALUE self )
@@ -460,7 +468,7 @@ ossl_fips_mode_get(VALUE self)
460468
461469/*
462470 * call-seq:
463- * OpenSSL.fips_mode = boolean -> boolean
471+ * OpenSSL.fips_mode = boolean
464472 *
465473 * Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an
466474 * effect for FIPS-capable installations of the OpenSSL library. Trying to do
@@ -503,13 +511,13 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
503511
504512/*
505513 * call-seq:
506- * OpenSSL.fixed_length_secure_compare(string, string) -> boolean
514+ * OpenSSL.fixed_length_secure_compare(string, string) -> true or false
507515 *
508516 * Constant time memory comparison for fixed length strings, such as results
509- * of HMAC calculations.
517+ * of \ HMAC calculations.
510518 *
511519 * Returns +true+ if the strings are identical, +false+ if they are of the same
512- * length but not identical. If the length is different, + ArgumentError+ is
520+ * length but not identical. If the length is different, ArgumentError is
513521 * raised.
514522 */
515523static VALUE
@@ -531,7 +539,7 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
531539}
532540
533541/*
534- * OpenSSL provides SSL, TLS and general purpose cryptography. It wraps the
542+ * OpenSSL provides \ SSL, TLS and general purpose cryptography. It wraps the
535543 * OpenSSL[https://www.openssl.org/] library.
536544 *
537545 * = Examples
@@ -899,23 +907,23 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
899907 * io.write csr_cert.to_pem
900908 * end
901909 *
902- * == SSL and TLS Connections
910+ * == \ SSL and TLS Connections
903911 *
904- * Using our created key and certificate we can create an SSL or TLS connection.
905- * An SSLContext is used to set up an SSL session.
912+ * Using our created key and certificate we can create an \ SSL or TLS
913+ * connection. An OpenSSL::SSL:: SSLContext is used to set up an \ SSL session.
906914 *
907915 * context = OpenSSL::SSL::SSLContext.new
908916 *
909- * === SSL Server
917+ * === \ SSL Server
910918 *
911- * An SSL server requires the certificate and private key to communicate
919+ * An \ SSL server requires the certificate and private key to communicate
912920 * securely with its clients:
913921 *
914922 * context.cert = cert
915923 * context.key = key
916924 *
917- * Then create an SSLServer with a TCP server socket and the context. Use the
918- * SSLServer like an ordinary TCP server.
925+ * Then create an OpenSSL::SSL:: SSLServer with a TCP server socket and the
926+ * context. Use the SSLServer like an ordinary TCP server.
919927 *
920928 * require 'socket'
921929 *
@@ -934,14 +942,15 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
934942 * ssl_connection.close
935943 * end
936944 *
937- * === SSL client
945+ * === \ SSL client
938946 *
939- * An SSL client is created with a TCP socket and the context.
940- * SSLSocket#connect must be called to initiate the SSL handshake and start
941- * encryption. A key and certificate are not required for the client socket.
947+ * An \SSL client is created with a TCP socket and the context.
948+ * OpenSSL::SSL::SSLSocket#connect must be called to initiate the \SSL handshake
949+ * and start encryption. A key and certificate are not required for the client
950+ * socket.
942951 *
943- * Note that SSLSocket#close doesn't close the underlying socket by default. Set
944- * SSLSocket#sync_close to true if you want.
952+ * Note that OpenSSL::SSL:: SSLSocket#close doesn't close the underlying socket
953+ * by default. Set OpenSSL::SSL:: SSLSocket#sync_close to true if you want.
945954 *
946955 * require 'socket'
947956 *
@@ -957,7 +966,7 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
957966 *
958967 * === Peer Verification
959968 *
960- * An unverified SSL connection does not provide much security. For enhanced
969+ * An unverified \ SSL connection does not provide much security. For enhanced
961970 * security the client or server can verify the certificate of its peer.
962971 *
963972 * The client can be modified to verify the server's certificate against the
@@ -1008,13 +1017,14 @@ Init_openssl(void)
10081017 rb_define_singleton_method (mOSSL , "fixed_length_secure_compare" , ossl_crypto_fixed_length_secure_compare , 2 );
10091018
10101019 /*
1011- * Version of OpenSSL the ruby OpenSSL extension was built with
1020+ * OpenSSL library version string used to compile the Ruby OpenSSL
1021+ * extension. This may differ from the version used at runtime.
10121022 */
10131023 rb_define_const (mOSSL , "OPENSSL_VERSION" ,
10141024 rb_obj_freeze (rb_str_new_cstr (OPENSSL_VERSION_TEXT )));
10151025
10161026 /*
1017- * Version of OpenSSL the ruby OpenSSL extension is running with
1027+ * OpenSSL library version string currently used at runtime.
10181028 */
10191029 rb_define_const (
10201030 mOSSL ,
@@ -1023,30 +1033,40 @@ Init_openssl(void)
10231033 );
10241034
10251035 /*
1026- * Version number of OpenSSL the ruby OpenSSL extension was built with
1027- * (base 16). The formats are below .
1036+ * OpenSSL library version number used to compile the Ruby OpenSSL
1037+ * extension. This may differ from the version used at runtime .
10281038 *
1029- * [OpenSSL 3] <tt>0xMNN00PP0 (major minor 00 patch 0)</tt>
1030- * [OpenSSL before 3] <tt>0xMNNFFPPS (major minor fix patch status)</tt>
1031- * [LibreSSL] <tt>0x20000000 (fixed value)</tt>
1039+ * The version number is encoded into a single integer value. The number
1040+ * follows the format:
1041+ *
1042+ * [OpenSSL 3.0.0 or later] <tt>0xMNN00PP0</tt> (major minor 00 patch 0)
1043+ * [OpenSSL 1.1.1 or earlier] <tt>0xMNNFFPPS</tt> (major minor fix patch status)
1044+ * [LibreSSL] <tt>0x20000000</tt> (a fixed value)
10321045 *
10331046 * See also the man page OPENSSL_VERSION_NUMBER(3).
10341047 */
10351048 rb_define_const (mOSSL , "OPENSSL_VERSION_NUMBER" , INT2NUM (OPENSSL_VERSION_NUMBER ));
10361049
10371050#if defined(LIBRESSL_VERSION_NUMBER )
10381051 /*
1039- * Version number of LibreSSL the ruby OpenSSL extension was built with
1040- * (base 16). The format is <tt>0xMNNFF00f (major minor fix 00
1041- * status)</tt>. This constant is only defined in LibreSSL cases.
1052+ * LibreSSL library version number used to compile the Ruby OpenSSL
1053+ * extension. This may differ from the version used at runtime.
1054+ *
1055+ * This constant is only defined if the extension was compiled against
1056+ * LibreSSL. The number follows the format:
1057+ * <tt>0xMNNFF00f</tt> (major minor fix 00 status).
10421058 *
10431059 * See also the man page LIBRESSL_VERSION_NUMBER(3).
10441060 */
10451061 rb_define_const (mOSSL , "LIBRESSL_VERSION_NUMBER" , INT2NUM (LIBRESSL_VERSION_NUMBER ));
10461062#endif
10471063
10481064 /*
1049- * Boolean indicating whether OpenSSL is FIPS-capable or not
1065+ * Boolean indicating whether the OpenSSL library is FIPS-capable or not.
1066+ * Always <tt>true</tt> for OpenSSL 3.0 or later.
1067+ *
1068+ * This is obsolete and will be removed in the future.
1069+ * See also OpenSSL.fips_mode.
10501070 */
10511071 rb_define_const (mOSSL , "OPENSSL_FIPS" ,
10521072/* OpenSSL 3 is FIPS-capable even when it is installed without fips option */
0 commit comments