-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathfmqssl.cpp
More file actions
34 lines (27 loc) · 784 Bytes
/
fmqssl.cpp
File metadata and controls
34 lines (27 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <openssl/ssl.h>
#include "fmqssl.h"
FmqSsl::~FmqSsl()
{
if (!d) return;
/*
* We write the shutdown when we can, but don't take error conditions into account. If socket buffers are full, because
* clients disappear for instance, the socket is just closed. We don't care.
*
* Truncation attacks seem irrelevant. MQTT is frame based, so either end knows if the transmission is done or not. The
* close_notify is not used in determining whether to use or discard the received data.
*/
SSL_shutdown(d.get());
}
FmqSsl::FmqSsl() :
d(nullptr, SSL_free)
{
}
FmqSsl::FmqSsl(const SslCtxManager &ssl_ctx) :
d(SSL_new(ssl_ctx.get()), SSL_free)
{
}
void FmqSsl::set_fd(int fd)
{
if (!d) return;
SSL_set_fd(d.get(), fd);
}