1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include <openssl/ssl.h>
17 #include <openssl/err.h>
20 #include <openssl/applink.c>
23 #include "configreader.h"
31 #include "transport.h"
34 #pragma comment(lib, "libeay32MTd")
35 #pragma comment(lib, "ssleay32MTd")
36 #undef MAX_DESCRIPTORS
37 #define MAX_DESCRIPTORS 10000
40 /* $ModDesc: Provides SSL support for clients */
41 /* $CompileFlags: pkgconfversion("openssl","0.9.7") pkgconfincludes("openssl","/openssl/ssl.h","") */
42 /* $LinkerFlags: rpath("pkg-config --libs openssl") pkgconflibs("openssl","/libssl.so","-lssl -lcrypto -ldl") */
43 /* $ModDep: transport.h */
45 enum issl_status { ISSL_NONE, ISSL_HANDSHAKING, ISSL_OPEN };
46 enum issl_io_status { ISSL_WRITE, ISSL_READ };
48 static bool SelfSigned = false;
50 bool isin(int port, const std::vector<int> &portlist)
52 for(unsigned int i = 0; i < portlist.size(); i++)
53 if(portlist[i] == port)
61 return ERR_error_string(ERR_get_error(), NULL);
64 static int error_callback(const char *str, size_t len, void *u);
66 /** Represents an SSL user's extra data
68 class issl_session : public classbase
76 unsigned int inbufoffset;
77 char* inbuf; // Buffer OpenSSL reads into.
78 std::string outbuf; // Buffer for outgoing data that OpenSSL will not take.
90 static int OnVerify(int preverify_ok, X509_STORE_CTX *ctx)
92 /* XXX: This will allow self signed certificates.
93 * In the future if we want an option to not allow this,
94 * we can just return preverify_ok here, and openssl
95 * will boot off self-signed and invalid peer certs.
97 int ve = X509_STORE_CTX_get_error(ctx);
99 SelfSigned = (ve == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
104 class ModuleSSLOpenSSL : public Module
106 std::vector<int> listenports;
109 issl_session sessions[MAX_DESCRIPTORS];
118 std::string certfile;
120 // std::string crlfile;
122 std::string sslports;
128 InspIRCd* PublicInstance;
130 ModuleSSLOpenSSL(InspIRCd* Me)
131 : Module(Me), PublicInstance(Me)
133 ServerInstance->Modules->PublishInterface("BufferedSocketHook", this);
135 // Not rehashable...because I cba to reduce all the sizes of existing buffers.
136 inbufsize = ServerInstance->Config->NetBufferSize;
138 /* Global SSL library initialization*/
140 SSL_load_error_strings();
142 /* Build our SSL contexts:
143 * NOTE: OpenSSL makes us have two contexts, one for servers and one for clients. ICK.
145 ctx = SSL_CTX_new( SSLv23_server_method() );
146 clictx = SSL_CTX_new( SSLv23_client_method() );
148 SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify);
149 SSL_CTX_set_verify(clictx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify);
151 // Needs the flag as it ignores a plain /rehash
152 OnRehash(NULL,"ssl");
155 virtual void OnRehash(User* user, const std::string ¶m)
160 ConfigReader Conf(ServerInstance);
162 for (unsigned int i = 0; i < listenports.size(); i++)
164 ServerInstance->Config->DelIOHook(listenports[i]);
171 for (int i = 0; i < Conf.Enumerate("bind"); i++)
173 // For each <bind> tag
174 std::string x = Conf.ReadValue("bind", "type", i);
175 if (((x.empty()) || (x == "clients")) && (Conf.ReadValue("bind", "ssl", i) == "openssl"))
177 // Get the port we're meant to be listening on with SSL
178 std::string port = Conf.ReadValue("bind", "port", i);
179 irc::portparser portrange(port, false);
181 while ((portno = portrange.GetToken()))
186 if (ServerInstance->Config->AddIOHook(portno, this))
188 listenports.push_back(portno);
189 for (size_t i = 0; i < ServerInstance->Config->ports.size(); i++)
190 if (ServerInstance->Config->ports[i]->GetPort() == portno)
191 ServerInstance->Config->ports[i]->SetDescription("ssl");
192 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %d", portno);
193 sslports.append("*:").append(ConvToStr(portno)).append(";");
197 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?", portno);
200 catch (ModuleException &e)
202 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %d: %s. Maybe it's already hooked by the same port on a different IP, or you have another SSL or similar module loaded?", portno, e.GetReason());
208 if (!sslports.empty())
209 sslports.erase(sslports.end() - 1);
211 std::string confdir(ServerInstance->ConfigFileName);
212 // +1 so we the path ends with a /
213 confdir = confdir.substr(0, confdir.find_last_of('/') + 1);
215 cafile = Conf.ReadValue("openssl", "cafile", 0);
216 certfile = Conf.ReadValue("openssl", "certfile", 0);
217 keyfile = Conf.ReadValue("openssl", "keyfile", 0);
218 dhfile = Conf.ReadValue("openssl", "dhfile", 0);
220 // Set all the default values needed.
224 if (certfile.empty())
225 certfile = "cert.pem";
231 dhfile = "dhparams.pem";
233 // Prepend relative paths with the path to the config directory.
234 if (cafile[0] != '/')
235 cafile = confdir + cafile;
237 if (certfile[0] != '/')
238 certfile = confdir + certfile;
240 if (keyfile[0] != '/')
241 keyfile = confdir + keyfile;
243 if (dhfile[0] != '/')
244 dhfile = confdir + dhfile;
246 /* Load our keys and certificates
247 * NOTE: OpenSSL's error logging API sucks, don't blame us for this clusterfuck.
249 if ((!SSL_CTX_use_certificate_chain_file(ctx, certfile.c_str())) || (!SSL_CTX_use_certificate_chain_file(clictx, certfile.c_str())))
251 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read certificate file %s. %s", certfile.c_str(), strerror(errno));
252 ERR_print_errors_cb(error_callback, this);
255 if (((!SSL_CTX_use_PrivateKey_file(ctx, keyfile.c_str(), SSL_FILETYPE_PEM))) || (!SSL_CTX_use_PrivateKey_file(clictx, keyfile.c_str(), SSL_FILETYPE_PEM)))
257 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read key file %s. %s", keyfile.c_str(), strerror(errno));
258 ERR_print_errors_cb(error_callback, this);
261 /* Load the CAs we trust*/
262 if (((!SSL_CTX_load_verify_locations(ctx, cafile.c_str(), 0))) || (!SSL_CTX_load_verify_locations(clictx, cafile.c_str(), 0)))
264 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read CA list from %s. %s", cafile.c_str(), strerror(errno));
265 ERR_print_errors_cb(error_callback, this);
268 FILE* dhpfile = fopen(dhfile.c_str(), "r");
273 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so Couldn't open DH file %s: %s", dhfile.c_str(), strerror(errno));
274 throw ModuleException("Couldn't open DH file " + dhfile + ": " + strerror(errno));
278 ret = PEM_read_DHparams(dhpfile, NULL, NULL, NULL);
279 if ((SSL_CTX_set_tmp_dh(ctx, ret) < 0) || (SSL_CTX_set_tmp_dh(clictx, ret) < 0))
281 ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Couldn't set DH parameters %s. SSL errors follow:", dhfile.c_str());
282 ERR_print_errors_cb(error_callback, this);
289 virtual void On005Numeric(std::string &output)
291 output.append(" SSL=" + sslports);
294 virtual ~ModuleSSLOpenSSL()
297 SSL_CTX_free(clictx);
300 virtual void OnCleanup(int target_type, void* item)
302 if (target_type == TYPE_USER)
304 User* user = (User*)item;
306 if (user->GetExt("ssl", dummy) && IS_LOCAL(user) && isin(user->GetPort(), listenports))
308 // User is using SSL, they're a local user, and they're using one of *our* SSL ports.
309 // Potentially there could be multiple SSL modules loaded at once on different ports.
310 User::QuitUser(ServerInstance, user, "SSL module unloading");
312 if (user->GetExt("ssl_cert", dummy) && isin(user->GetPort(), listenports))
315 user->GetExt("ssl_cert", tofree);
317 user->Shrink("ssl_cert");
322 virtual void OnUnloadModule(Module* mod, const std::string &name)
326 for(unsigned int i = 0; i < listenports.size(); i++)
328 ServerInstance->Config->DelIOHook(listenports[i]);
329 for (size_t j = 0; j < ServerInstance->Config->ports.size(); j++)
330 if (ServerInstance->Config->ports[j]->GetPort() == listenports[i])
331 ServerInstance->Config->ports[j]->SetDescription("plaintext");
336 virtual Version GetVersion()
338 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
341 void Implements(char* List)
343 List[I_OnRawSocketConnect] = List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = List[I_OnCleanup] = List[I_On005Numeric] = 1;
344 List[I_OnBufferFlushed] = List[I_OnRequest] = List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUnloadModule] = List[I_OnRehash] = List[I_OnWhois] = List[I_OnPostConnect] = 1;
347 virtual char* OnRequest(Request* request)
349 ISHRequest* ISR = (ISHRequest*)request;
350 if (strcmp("IS_NAME", request->GetId()) == 0)
354 else if (strcmp("IS_HOOK", request->GetId()) == 0)
359 ret = ServerInstance->Config->AddIOHook((Module*)this, (BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL;
361 catch (ModuleException &e)
368 else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
370 return ServerInstance->Config->DelIOHook((BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL;
372 else if (strcmp("IS_HSDONE", request->GetId()) == 0)
374 if (ISR->Sock->GetFd() < 0)
377 issl_session* session = &sessions[ISR->Sock->GetFd()];
378 return (session->status == ISSL_HANDSHAKING) ? NULL : (char*)"OK";
380 else if (strcmp("IS_ATTACH", request->GetId()) == 0)
382 issl_session* session = &sessions[ISR->Sock->GetFd()];
385 VerifyCertificate(session, (BufferedSocket*)ISR->Sock);
393 virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
395 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
396 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
399 issl_session* session = &sessions[fd];
402 session->inbuf = new char[inbufsize];
403 session->inbufoffset = 0;
404 session->sess = SSL_new(ctx);
405 session->status = ISSL_NONE;
406 session->outbound = false;
408 if (session->sess == NULL)
411 if (SSL_set_fd(session->sess, fd) == 0)
413 ServerInstance->Log(DEBUG,"BUG: Can't set fd with SSL_set_fd: %d", fd);
417 ServerInstance->Log(DEBUG,"OnRawSocketAccept begin handshake");
422 virtual void OnRawSocketConnect(int fd)
424 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
425 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
428 issl_session* session = &sessions[fd];
431 session->inbuf = new char[inbufsize];
432 session->inbufoffset = 0;
433 session->sess = SSL_new(clictx);
434 session->status = ISSL_NONE;
435 session->outbound = true;
437 if (session->sess == NULL)
440 if (SSL_set_fd(session->sess, fd) == 0)
442 ServerInstance->Log(DEBUG,"BUG: Can't set fd with SSL_set_fd: %d", fd);
449 virtual void OnRawSocketClose(int fd)
451 ServerInstance->Log(DEBUG,"OnRawSocketClose %d", fd);
452 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
453 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
456 CloseSession(&sessions[fd]);
458 EventHandler* user = ServerInstance->SE->GetRef(fd);
460 if ((user) && (user->GetExt("ssl_cert", dummy)))
463 user->GetExt("ssl_cert", tofree);
465 user->Shrink("ssl_cert");
469 virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult)
471 ServerInstance->Log(DEBUG,"OnRawSocketRead");
472 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
473 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
476 issl_session* session = &sessions[fd];
481 CloseSession(session);
485 if (session->status == ISSL_HANDSHAKING)
487 if (session->rstat == ISSL_READ || session->wstat == ISSL_READ)
489 // The handshake isn't finished and it wants to read, try to finish it.
490 if (!Handshake(session))
492 // Couldn't resume handshake.
503 // If we resumed the handshake then session->status will be ISSL_OPEN
505 if (session->status == ISSL_OPEN)
507 if (session->wstat == ISSL_READ)
509 if(DoWrite(session) == 0)
513 if (session->rstat == ISSL_READ)
515 int ret = DoRead(session);
517 ServerInstance->Log(DEBUG, "<***> DoRead count: " + ConvToStr(count));
518 ServerInstance->Log(DEBUG, "<***> DoRead ret: " + ConvToStr(ret));
519 ServerInstance->Log(DEBUG, "<***> DoRead session->inbufoffset: " + ConvToStr(session->inbufoffset));
523 if (count <= session->inbufoffset)
525 memcpy(buffer, session->inbuf, count);
526 // Move the stuff left in inbuf to the beginning of it
527 memcpy(session->inbuf, session->inbuf + count, (session->inbufoffset - count));
528 // Now we need to set session->inbufoffset to the amount of data still waiting to be handed to insp.
529 session->inbufoffset -= count;
530 // Insp uses readresult as the count of how much data there is in buffer, so:
535 // There's not as much in the inbuf as there is space in the buffer, so just copy the whole thing.
536 memcpy(buffer, session->inbuf, session->inbufoffset);
538 readresult = session->inbufoffset;
539 // Zero the offset, as there's nothing there..
540 session->inbufoffset = 0;
542 ServerInstance->Log(DEBUG,"Read result=%d",readresult);
552 virtual int OnRawSocketWrite(int fd, const char* buffer, int count)
554 /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
555 if ((fd < 0) || (fd > MAX_DESCRIPTORS))
558 issl_session* session = &sessions[fd];
562 CloseSession(session);
566 session->outbuf.append(buffer, count);
567 MakePollWrite(session);
569 if (session->status == ISSL_HANDSHAKING)
571 // The handshake isn't finished, try to finish it.
572 if (session->rstat == ISSL_WRITE || session->wstat == ISSL_WRITE)
578 if (session->status == ISSL_OPEN)
580 if (session->rstat == ISSL_WRITE)
585 if (session->wstat == ISSL_WRITE)
587 return DoWrite(session);
594 int DoWrite(issl_session* session)
596 if (!session->outbuf.size())
599 int ret = SSL_write(session->sess, session->outbuf.data(), session->outbuf.size());
603 CloseSession(session);
608 int err = SSL_get_error(session->sess, ret);
610 if (err == SSL_ERROR_WANT_WRITE)
612 session->wstat = ISSL_WRITE;
615 else if (err == SSL_ERROR_WANT_READ)
617 session->wstat = ISSL_READ;
622 CloseSession(session);
628 session->outbuf = session->outbuf.substr(ret);
633 int DoRead(issl_session* session)
635 // Is this right? Not sure if the unencrypted data is garaunteed to be the same length.
636 // Read into the inbuffer, offset from the beginning by the amount of data we have that insp hasn't taken yet.
638 int ret = SSL_read(session->sess, session->inbuf + session->inbufoffset, inbufsize - session->inbufoffset);
642 // Client closed connection.
643 CloseSession(session);
648 int err = SSL_get_error(session->sess, ret);
650 if (err == SSL_ERROR_WANT_READ)
652 session->rstat = ISSL_READ;
655 else if (err == SSL_ERROR_WANT_WRITE)
657 session->rstat = ISSL_WRITE;
658 MakePollWrite(session);
663 CloseSession(session);
669 // Read successfully 'ret' bytes into inbuf + inbufoffset
670 // There are 'ret' + 'inbufoffset' bytes of data in 'inbuf'
671 // 'buffer' is 'count' long
673 session->inbufoffset += ret;
679 // :kenny.chatspike.net 320 Om Epy|AFK :is a Secure Connection
680 virtual void OnWhois(User* source, User* dest)
685 // Bugfix, only send this numeric for *our* SSL users
686 if (dest->GetExt("ssl", dummy) || (IS_LOCAL(dest) && isin(dest->GetPort(), listenports)))
688 ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick, dest->nick);
692 virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
694 // check if the linking module wants to know about OUR metadata
695 if (extname == "ssl")
697 // check if this user has an swhois field to send
698 if(user->GetExt(extname, dummy))
700 // call this function in the linking module, let it format the data how it
701 // sees fit, and send it on its way. We dont need or want to know how.
702 proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, displayable ? "Enabled" : "ON");
707 virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
709 // check if its our metadata key, and its associated with a user
710 if ((target_type == TYPE_USER) && (extname == "ssl"))
712 User* dest = (User*)target;
713 // if they dont already have an ssl flag, accept the remote server's
714 if (!dest->GetExt(extname, dummy))
716 dest->Extend(extname, "ON");
721 bool Handshake(issl_session* session)
725 if (session->outbound)
726 ret = SSL_connect(session->sess);
728 ret = SSL_accept(session->sess);
732 int err = SSL_get_error(session->sess, ret);
734 if (err == SSL_ERROR_WANT_READ)
736 ServerInstance->Log(DEBUG,"Handshake Want read");
737 session->rstat = ISSL_READ;
738 session->status = ISSL_HANDSHAKING;
741 else if (err == SSL_ERROR_WANT_WRITE)
743 ServerInstance->Log(DEBUG,"Handshake Want write");
744 session->wstat = ISSL_WRITE;
745 session->status = ISSL_HANDSHAKING;
746 MakePollWrite(session);
751 ServerInstance->Log(DEBUG,"Handshake close session");
752 CloseSession(session);
759 ServerInstance->Log(DEBUG,"Handshake complete");
760 // Handshake complete.
761 // This will do for setting the ssl flag...it could be done earlier if it's needed. But this seems neater.
762 User* u = ServerInstance->FindDescriptor(session->fd);
765 if (!u->GetExt("ssl", dummy))
766 u->Extend("ssl", "ON");
769 session->status = ISSL_OPEN;
771 MakePollWrite(session);
777 int ssl_err = SSL_get_error(session->sess, ret);
779 ERR_print_errors_fp(stderr);
780 ServerInstance->Log(DEBUG,"Handshake fail 2: %d: %s", ssl_err, ERR_error_string(ssl_err,buf));
781 CloseSession(session);
788 virtual void OnPostConnect(User* user)
790 // This occurs AFTER OnUserConnect so we can be sure the
791 // protocol module has propagated the NICK message.
792 if ((user->GetExt("ssl", dummy)) && (IS_LOCAL(user)))
794 // Tell whatever protocol module we're using that we need to inform other servers of this metadata NOW.
795 std::deque<std::string>* metadata = new std::deque<std::string>;
796 metadata->push_back(user->nick);
797 metadata->push_back("ssl"); // The metadata id
798 metadata->push_back("ON"); // The value to send
799 Event* event = new Event((char*)metadata,(Module*)this,"send_metadata");
800 event->Send(ServerInstance); // Trigger the event. We don't care what module picks it up.
804 VerifyCertificate(&sessions[user->GetFd()], user);
805 if (sessions[user->GetFd()].sess)
806 user->WriteServ("NOTICE %s :*** You are connected using SSL cipher \"%s\"", user->nick, SSL_get_cipher(sessions[user->GetFd()].sess));
810 void MakePollWrite(issl_session* session)
812 //OnRawSocketWrite(session->fd, NULL, 0);
813 EventHandler* eh = ServerInstance->FindDescriptor(session->fd);
816 ServerInstance->SE->WantWrite(eh);
817 ServerInstance->Log(DEBUG,"Made want write");
820 ServerInstance->Log(DEBUG,"Couldnt find descriptor to make writeable!");
823 virtual void OnBufferFlushed(User* user)
825 if (user->GetExt("ssl"))
827 issl_session* session = &sessions[user->GetFd()];
828 if (session && session->outbuf.size())
829 OnRawSocketWrite(user->GetFd(), NULL, 0);
833 void CloseSession(issl_session* session)
837 SSL_shutdown(session->sess);
838 SSL_free(session->sess);
843 delete[] session->inbuf;
846 session->outbuf.clear();
847 session->inbuf = NULL;
848 session->sess = NULL;
849 session->status = ISSL_NONE;
852 void VerifyCertificate(issl_session* session, Extensible* user)
854 if (!session->sess || !user)
858 ssl_cert* certinfo = new ssl_cert;
860 unsigned char md[EVP_MAX_MD_SIZE];
861 const EVP_MD *digest = EVP_md5();
863 user->Extend("ssl_cert",certinfo);
865 cert = SSL_get_peer_certificate((SSL*)session->sess);
869 certinfo->data.insert(std::make_pair("error","Could not get peer certificate: "+std::string(get_error())));
873 certinfo->data.insert(std::make_pair("invalid", SSL_get_verify_result(session->sess) != X509_V_OK ? ConvToStr(1) : ConvToStr(0)));
877 certinfo->data.insert(std::make_pair("unknownsigner",ConvToStr(0)));
878 certinfo->data.insert(std::make_pair("trusted",ConvToStr(1)));
882 certinfo->data.insert(std::make_pair("unknownsigner",ConvToStr(1)));
883 certinfo->data.insert(std::make_pair("trusted",ConvToStr(0)));
886 certinfo->data.insert(std::make_pair("dn",std::string(X509_NAME_oneline(X509_get_subject_name(cert),0,0))));
887 certinfo->data.insert(std::make_pair("issuer",std::string(X509_NAME_oneline(X509_get_issuer_name(cert),0,0))));
889 if (!X509_digest(cert, digest, md, &n))
891 certinfo->data.insert(std::make_pair("error","Out of memory generating fingerprint"));
895 certinfo->data.insert(std::make_pair("fingerprint",irc::hex(md, n)));
898 if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), time(NULL)) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), time(NULL)) == 0))
900 certinfo->data.insert(std::make_pair("error","Not activated, or expired certificate"));
907 static int error_callback(const char *str, size_t len, void *u)
909 ModuleSSLOpenSSL* mssl = (ModuleSSLOpenSSL*)u;
910 mssl->PublicInstance->Log(DEFAULT, "SSL error: " + std::string(str, len - 1));
914 MODULE_INIT(ModuleSSLOpenSSL);