[Libreoffice-commits] online.git: Branch 'private/Ashod/nonblocking' - net/socket.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sat Feb 18 00:41:54 UTC 2017
net/socket.hpp | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
New commits:
commit 9707cf5e54dbacf32264f9702811e3ec62364681
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Fri Feb 17 13:01:48 2017 -0500
nb: create SSL socket
Change-Id: I2d5cc3441bcdb67b868557fefe93e2d0bd7770af
Reviewed-on: https://gerrit.libreoffice.org/34389
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/net/socket.hpp b/net/socket.hpp
index 5332456..8982380 100644
--- a/net/socket.hpp
+++ b/net/socket.hpp
@@ -20,6 +20,8 @@
#include <Poco/Net/SocketAddress.h>
+#include "ssl.hpp"
+
/// A non-blocking, streaming socket.
class Socket
{
@@ -406,11 +408,34 @@ public:
protected:
SslStreamSocket(const int fd) :
- BufferingSocket(fd)
+ BufferingSocket(fd),
+ _ssl(nullptr)
{
+ BIO* bio = BIO_new(BIO_s_socket());
+ if (bio == nullptr)
+ {
+ throw std::runtime_error("Failed to create SSL BIO.");
+ }
+
+ BIO_set_fd(bio, fd, BIO_NOCLOSE);
+
+ _ssl = SslContext::newSsl();
+ if (!_ssl)
+ {
+ BIO_free(bio);
+ throw std::runtime_error("Failed to create SSL.");
+ }
+
+ SSL_set_bio(_ssl, bio, bio);
+
+ // We are a server-side socket.
+ SSL_set_accept_state(_ssl);
}
friend class ServerSocket;
+
+private:
+ SSL* _ssl;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list