Bug 1161807 - [RFE] API to convert SSL version number to SSL version string
Summary: [RFE] API to convert SSL version number to SSL version string
Alias: None
Product: Fedora
Classification: Fedora
Component: nss
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: nss-nspr-maint
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2014-11-07 23:14 UTC by Noriko Hosoi
Modified: 2019-05-17 08:19 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2019-05-17 08:19:21 UTC
Type: Bug

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Mozilla Foundation 480174 None None None 2019-06-11 13:12:27 UTC

Description Noriko Hosoi 2014-11-07 23:14:37 UTC
Description of problem:
We, an NSS application, have many places to log or return an SSL version string in the human readable manner, e.g., "SSL3", "TLS1.3, and so on.  Currently, we are generating the string in our code, which may become obsolete or invalid any time if NSS change the value of the following macros.  Instead of assuming these values, we'd like to have the official API to get the SSL version string.
+ * nss3/sslproto.h
+ * #define SSL_LIBRARY_VERSION_2                   0x0002
+ * #define SSL_LIBRARY_VERSION_3_0                 0x0300
+ * #define SSL_LIBRARY_VERSION_TLS_1_0             0x0301
+ * #define SSL_LIBRARY_VERSION_TLS_1_1             0x0302
+ * #define SSL_LIBRARY_VERSION_TLS_1_2             0x0303
+ * #define SSL_LIBRARY_VERSION_TLS_1_3             0x0304

Comment 1 Noriko Hosoi 2014-11-10 23:31:20 UTC
FYI: We "temporarily" implemented this get SSL version string helper function in the Directory Server code (slapd/ssl.c).  We'd like to replace this function with the official API provided by NSS.

 * If non NULL buf and positive bufsize is given,
 * the memory is used to store the version string.
 * Otherwise, the memory for the string is allocated.
 * The latter case, caller is responsible to free it.
char *
slapi_getSSLVersion_str(PRUint16 vnum, char *buf, size_t bufsize)
    char *vstr = buf;
    if (vnum >= SSL_LIBRARY_VERSION_3_0) {
        if (vnum == SSL_LIBRARY_VERSION_3_0) { /* SSL3 */
            if (buf && bufsize) {
                PR_snprintf(buf, bufsize, "SSL3");
            } else {
                vstr = slapi_ch_smprintf("SSL3");
        } else { /* TLS v X.Y */
            const char *TLSFMT = "TLS%d.%d";
            int minor_offset = 0; /* e.g. 0x0401 -> TLS v 2.1, not 2.0 */

            if ((vnum & SSL_LIBRARY_VERSION_3_0) == SSL_LIBRARY_VERSION_3_0) {
                minor_offset = 1; /* e.g. 0x0301 -> TLS v 1.0, not 1.1 */
            if (buf && bufsize) {
                PR_snprintf(buf, bufsize, TLSFMT, (vnum >> 8) - 2, (vnum & 0xff) - minor_offset);
            } else {
                vstr = slapi_ch_smprintf(TLSFMT, (vnum >> 8) - 2, (vnum & 0xff) - minor_offset);
    } else if (vnum == SSL_LIBRARY_VERSION_2) { /* SSL2 */
        if (buf && bufsize) {
            PR_snprintf(buf, bufsize, "SSL2");
        } else {
            vstr = slapi_ch_smprintf("SSL2");
    } else {
        if (buf && bufsize) {
            PR_snprintf(buf, bufsize, "Unknown SSL version: 0x%x", vnum);
        } else {
            vstr = slapi_ch_smprintf("Unknown SSL version: 0x%x", vnum);
    return vstr;

Comment 2 Fedora End Of Life 2015-05-29 13:14:59 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Fedora End Of Life 2015-06-29 23:12:17 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 4 Kamil Dudka 2015-06-30 06:35:35 UTC
Still an issue in Fedora rawhide.

Comment 5 Fedora Admin XMLRPC Client 2016-08-15 15:52:27 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 6 Kai Engert (:kaie) (inactive account) 2016-11-18 13:05:56 UTC

These functions have been available since NSPR 4.8.9 and NSS 3.13

Comment 7 Kamil Dudka 2016-11-18 13:41:30 UTC
(In reply to Kai Engert (:kaie) from comment #6)
> NSSUTIL_GetVersion
> NSS_GetVersion
> NSSSSL_GetVersion
> NSSSMIME_GetVersion
> PR_GetVersion
> These functions have been available since NSPR 4.8.9 and NSS 3.13

How are the above functions related to the problem described in comment #0 and comment #1 (translation of SSL version enumeration constants to strings)?

Comment 8 Kai Engert (:kaie) (inactive account) 2016-11-18 13:57:57 UTC
I misinterpreted the request, I thought you'd like a version string for the NSS library version.

Feature enhancement requests liks this should be reported upstream, where the software development takes place (not in Fedora where we're mostly doing packaging).

Comment 9 Kai Engert (:kaie) (inactive account) 2017-07-11 13:39:36 UTC
still haven't been requested upstream.

Comment 10 Kamil Dudka 2017-07-11 13:57:19 UTC
(In reply to Kai Engert (:kaie) from comment #9)
> still haven't been requested upstream.

I believe this was requested 9 years ago:


Comment 11 Kai Engert (:kaie) (inactive account) 2017-07-11 14:20:44 UTC
I thought that mozilla bug was for fedora bug 917134.

Is this bug a duplicate of bug 917134 ?

Comment 12 Kai Engert (:kaie) (inactive account) 2017-07-11 14:21:03 UTC
Sorry, fedora bug 917133

Comment 13 Kamil Dudka 2017-07-11 14:58:25 UTC
Not really a duplicate but very similar (one is about cipher-suite names and one about SSL versions).  Anyway, I do not think that creating additional upstream requests is going to help us much...

Comment 14 Daiki Ueno 2019-05-17 08:19:21 UTC
I doubt such API is really useful.  As those codepoints are standardized in TLS, applications can safely rely on it.  Also the format of version numvers depends on application: some might want "SSL3" and the others might want "ssl3.0".  I'd rather leave this choice to applications.

Note You need to log in before you can comment on or make changes to this bug.