Process implementation for TLS encrypted traffic.
Process implementation for TLS encrypted traffic.
#include <fstream>
#include <iostream>
#include <poll.h>
{
int secureRead(char *buf, int count) override
{
}
void secureWrite(const char *buf, size_t count) override
{
}
std::vector<PdCom::Variable> vars ,
std::vector<std::string> ) override
{
for (const auto &v : vars)
std::cout << "Found var " << v.getPath() << "\n";
running_ = false;
}
{
std::cout << "Connected!" << std::endl;
}
public:
void waitForSocket()
{
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd_, &fds);
select(fd_ + 1, &fds, NULL, NULL, NULL);
}
MyProcess(const std::string &ca_pem, const char *host = "localhost") :
{
do {
std::cerr << "Handshaking\n";
}
bool running_ = true;
};
int main(int argc, char *argv[])
{
if (argc < 3) {
std::cerr << "Usage: " << argv[0] << " <hostname> <Path to CA.pem>\n";
return -1;
}
std::ifstream ca_file(argv[2]);
std::string ca;
getline(ca_file, ca, '\0');
MyProcess p(ca, argv[1]);
while (p.running_) {
p.waitForSocket();
p.asyncData();
}
p.bye();
return 0;
}
Wrapper around POSIX socket.
Definition: PosixProcess.h:45
void posixWriteDirect(const char *buf, size_t count)
Unbuffered Wrapper for write().
int posixRead(char *buf, int count)
Wrapper for read().
virtual void connected()=0
Protocol initialization completed.
virtual void listReply(std::vector< Variable > variables, std::vector< std::string > dirs)
Reply to list() call.
bool list(const std::string &path="")
List a directory path.
Definition: SecureProcess.h:41
bool handshake()
TLS Handshake.
static void InitLibrary()
GnuTls global initialization.