NSS_Shutdown refuses: objects are still open - but what/which ones ?

"R.Wieser" <[email protected]> Wed, 27 Jan 2021 09:54:47 +0100
Newsgroups gmane.comp.mozilla.general
Message-ID <[email protected]>
Hello all,

Some time ago I wrote an SSL socket "fetch" function to retrieve random 
resources from the web using FF v52.5.0 DLLs, which has worked well for me. 
But yesterday I tried call the "fetch" function twice in the same program, 
and the second time failed.

As it turns out, the NSS_Shutdown functions returns an error that it can't 
comply because some objects are still open.   And as it didn't shut down the 
next call to NSS_Initialize also fails.

I've been trying to zero-in on the culprit, but was unsuccessfull.   All I 
know that the problem only sticks its head up when data is actually 
exchanged (PR_Write, PR_Read).

In the below I've listed all calls in order they are made, in the hope 
somebody can spot which one(s) I've forgotten.

- - - - - - - - - - - - - - - - - - - -
PK11_ConfigurePKCS11,....
NSS_Initialize,...NSS_SetDomesticPolicy
;-- enable ciphers
SSL_OptionSetDefault,SSL_ENABLE_SSL2,PR_FALSE
SSL_OptionSetDefault,SSL_V2_COMPATIBLE_HELLO,PR_FALSE
SSL_OptionSetDefault,SSL_ENABLE_SESSION_TICKETS,PR_TRUE
SSL_OptionSetDefault,SSL_REQUIRE_SAFE_RENEGOTIATION,PR_FALSE
SSL_OptionSetDefault,SSL_ENABLE_RENEGOTIATION,2
SSL_OptionSetDefault,SSL_ENABLE_EXTENDED_MASTER_SECRET,PR_TRUE
SSL_OptionSetDefault,SSL_ENABLE_FALSE_START,PR_TRUE
SSL_OptionSetDefault,SSL_ENABLE_NPN,PR_TRUE
SSL_OptionSetDefault,SSL_ENABLE_ALPN,PR_TRUE
SSL_OptionSetDefault,SSL_ENABLE_0RTT_DATA,PR_FALSE
PK11_SetPasswordFunc,offset CBDummyPasswordFunc
....
PR_OpenTCPSocket,PR_AF_INET
SSL_ImportFD,0,[@@hSock]
...
SSL_HandshakeCallback,[@@hSock],....
SSL_AuthCertificateHook,[@@hSock],...
SSL_GetClientAuthDataHook,[@@hSock], ...
SSL_SetURL,[@@hSock],...
SSL_OptionSet,[@@hSock],SSL_ENABLE_OCSP_STAPLING,PR_TRUE
SSL_OptionSet,[@@hSock],SSL_ENABLE_SIGNED_CERT_TIMESTAMPS,PR_TRUE
SSL_OptionSet,[@@hSock],SSL_HANDSHAKE_AS_CLIENT,PR_TRUE
.....
PR_Write
PR_Read
.....
PK11_SetPasswordFunc,0
PR_Close,[@@hSock]
NSS_Shutdown
- - - - - - - - - - - - - - - - - - - -

Regards,
Rudy Wieser