Index: src/tls/OFGnuTLSTLSStream.m ================================================================== --- src/tls/OFGnuTLSTLSStream.m +++ src/tls/OFGnuTLSTLSStream.m @@ -127,15 +127,17 @@ [super dealloc]; } - (void)close { + if (_session == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; + if (_handshakeDone) gnutls_bye(_session, GNUTLS_SHUT_WR); - if (_session != NULL) - gnutls_deinit(_session); + gnutls_deinit(_session); if (_credentials != NULL) gnutls_certificate_free_credentials(_credentials); _session = NULL;