2018-09-27 23:56:48 +02:00
|
|
|
/*
|
|
|
|
* IXSocketAppleSSL.h
|
|
|
|
* Author: Benjamin Sergeant
|
|
|
|
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "IXSocket.h"
|
2018-12-15 01:28:11 +01:00
|
|
|
#include "IXCancellationRequest.h"
|
2018-09-27 23:56:48 +02:00
|
|
|
|
|
|
|
#include <Security/Security.h>
|
|
|
|
#include <Security/SecureTransport.h>
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
2019-02-21 03:59:07 +01:00
|
|
|
namespace ix
|
2018-09-27 23:56:48 +02:00
|
|
|
{
|
2019-02-21 03:59:07 +01:00
|
|
|
class SocketAppleSSL : public Socket
|
2018-09-27 23:56:48 +02:00
|
|
|
{
|
|
|
|
public:
|
2018-12-30 06:53:33 +01:00
|
|
|
SocketAppleSSL(int fd = -1);
|
2018-09-27 23:56:48 +02:00
|
|
|
~SocketAppleSSL();
|
|
|
|
|
2019-02-21 03:59:07 +01:00
|
|
|
virtual bool connect(const std::string& host,
|
2018-09-27 23:56:48 +02:00
|
|
|
int port,
|
2018-12-10 02:56:20 +01:00
|
|
|
std::string& errMsg,
|
2018-12-15 01:28:11 +01:00
|
|
|
const CancellationRequest& isCancellationRequested) final;
|
2018-09-27 23:56:48 +02:00
|
|
|
virtual void close() final;
|
|
|
|
|
2019-01-06 05:53:50 +01:00
|
|
|
virtual ssize_t send(char* buffer, size_t length) final;
|
|
|
|
virtual ssize_t send(const std::string& buffer) final;
|
|
|
|
virtual ssize_t recv(void* buffer, size_t length) final;
|
2018-09-27 23:56:48 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
SSLContextRef _sslContext;
|
|
|
|
mutable std::mutex _mutex; // AppleSSL routines are not thread-safe
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|