Remove orphaned files.
BUG= Review URL: https://codereview.webrtc.org/1827853003 Cr-Commit-Position: refs/heads/master@{#12138}
This commit is contained in:
@ -321,8 +321,6 @@ static_library("rtc_base") {
|
||||
"sslsocketfactory.h",
|
||||
"sslstreamadapter.cc",
|
||||
"sslstreamadapter.h",
|
||||
"sslstreamadapterhelper.cc",
|
||||
"sslstreamadapterhelper.h",
|
||||
"stream.cc",
|
||||
"stream.h",
|
||||
"task.cc",
|
||||
|
||||
@ -364,8 +364,6 @@
|
||||
'sslsocketfactory.h',
|
||||
'sslstreamadapter.cc',
|
||||
'sslstreamadapter.h',
|
||||
'sslstreamadapterhelper.cc',
|
||||
'sslstreamadapterhelper.h',
|
||||
'stream.cc',
|
||||
'stream.h',
|
||||
'task.cc',
|
||||
|
||||
@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "webrtc/base/sslstreamadapterhelper.h"
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/stream.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
SSLStreamAdapterHelper::SSLStreamAdapterHelper(StreamInterface* stream)
|
||||
: SSLStreamAdapter(stream),
|
||||
state_(SSL_NONE),
|
||||
role_(SSL_CLIENT),
|
||||
ssl_error_code_(0), // Not meaningful yet
|
||||
ssl_mode_(SSL_MODE_TLS),
|
||||
ssl_max_version_(SSL_PROTOCOL_TLS_12) {}
|
||||
|
||||
SSLStreamAdapterHelper::~SSLStreamAdapterHelper() = default;
|
||||
|
||||
void SSLStreamAdapterHelper::SetIdentity(SSLIdentity* identity) {
|
||||
ASSERT(identity_.get() == NULL);
|
||||
identity_.reset(identity);
|
||||
}
|
||||
|
||||
void SSLStreamAdapterHelper::SetServerRole(SSLRole role) {
|
||||
role_ = role;
|
||||
}
|
||||
|
||||
int SSLStreamAdapterHelper::StartSSLWithServer(const char* server_name) {
|
||||
ASSERT(server_name != NULL && server_name[0] != '\0');
|
||||
ssl_server_name_ = server_name;
|
||||
return StartSSL();
|
||||
}
|
||||
|
||||
int SSLStreamAdapterHelper::StartSSLWithPeer() {
|
||||
ASSERT(ssl_server_name_.empty());
|
||||
// It is permitted to specify peer_certificate_ only later.
|
||||
return StartSSL();
|
||||
}
|
||||
|
||||
void SSLStreamAdapterHelper::SetMode(SSLMode mode) {
|
||||
ASSERT(state_ == SSL_NONE);
|
||||
ssl_mode_ = mode;
|
||||
}
|
||||
|
||||
void SSLStreamAdapterHelper::SetMaxProtocolVersion(SSLProtocolVersion version) {
|
||||
ssl_max_version_ = version;
|
||||
}
|
||||
|
||||
StreamState SSLStreamAdapterHelper::GetState() const {
|
||||
switch (state_) {
|
||||
case SSL_WAIT:
|
||||
case SSL_CONNECTING:
|
||||
return SS_OPENING;
|
||||
case SSL_CONNECTED:
|
||||
return SS_OPEN;
|
||||
default:
|
||||
return SS_CLOSED;
|
||||
};
|
||||
// not reached
|
||||
}
|
||||
|
||||
bool SSLStreamAdapterHelper::GetPeerCertificate(SSLCertificate** cert) const {
|
||||
if (!peer_certificate_)
|
||||
return false;
|
||||
|
||||
*cert = peer_certificate_->GetReference();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SSLStreamAdapterHelper::SetPeerCertificateDigest(
|
||||
const std::string &digest_alg,
|
||||
const unsigned char* digest_val,
|
||||
size_t digest_len) {
|
||||
ASSERT(peer_certificate_.get() == NULL);
|
||||
ASSERT(peer_certificate_digest_algorithm_.empty());
|
||||
ASSERT(ssl_server_name_.empty());
|
||||
size_t expected_len;
|
||||
|
||||
if (!GetDigestLength(digest_alg, &expected_len)) {
|
||||
LOG(LS_WARNING) << "Unknown digest algorithm: " << digest_alg;
|
||||
return false;
|
||||
}
|
||||
if (expected_len != digest_len)
|
||||
return false;
|
||||
|
||||
peer_certificate_digest_value_.SetData(digest_val, digest_len);
|
||||
peer_certificate_digest_algorithm_ = digest_alg;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SSLStreamAdapterHelper::Error(const char* context, int err, bool signal) {
|
||||
LOG(LS_WARNING) << "SSLStreamAdapterHelper::Error("
|
||||
<< context << ", " << err << "," << signal << ")";
|
||||
state_ = SSL_ERROR;
|
||||
ssl_error_code_ = err;
|
||||
Cleanup();
|
||||
if (signal)
|
||||
StreamAdapterInterface::OnEvent(stream(), SE_CLOSE, err);
|
||||
}
|
||||
|
||||
void SSLStreamAdapterHelper::Close() {
|
||||
Cleanup();
|
||||
ASSERT(state_ == SSL_CLOSED || state_ == SSL_ERROR);
|
||||
StreamAdapterInterface::Close();
|
||||
}
|
||||
|
||||
int SSLStreamAdapterHelper::StartSSL() {
|
||||
ASSERT(state_ == SSL_NONE);
|
||||
|
||||
if (StreamAdapterInterface::GetState() != SS_OPEN) {
|
||||
state_ = SSL_WAIT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
state_ = SSL_CONNECTING;
|
||||
int err = BeginSSL();
|
||||
if (err) {
|
||||
Error("BeginSSL", err, false);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_BASE_SSLSTREAMADAPTERHELPER_H_
|
||||
#define WEBRTC_BASE_SSLSTREAMADAPTERHELPER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/buffer.h"
|
||||
#include "webrtc/base/stream.h"
|
||||
#include "webrtc/base/sslidentity.h"
|
||||
#include "webrtc/base/sslstreamadapter.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
// SSLStreamAdapterHelper : A stream adapter which implements much
|
||||
// of the logic that is common between the known implementations
|
||||
// (OpenSSL and previously NSS)
|
||||
class SSLStreamAdapterHelper : public SSLStreamAdapter {
|
||||
public:
|
||||
explicit SSLStreamAdapterHelper(StreamInterface* stream);
|
||||
~SSLStreamAdapterHelper() override;
|
||||
|
||||
// Overrides of SSLStreamAdapter
|
||||
void SetIdentity(SSLIdentity* identity) override;
|
||||
void SetServerRole(SSLRole role = SSL_SERVER) override;
|
||||
void SetMode(SSLMode mode) override;
|
||||
void SetMaxProtocolVersion(SSLProtocolVersion version) override;
|
||||
|
||||
int StartSSLWithServer(const char* server_name) override;
|
||||
int StartSSLWithPeer() override;
|
||||
|
||||
bool SetPeerCertificateDigest(const std::string& digest_alg,
|
||||
const unsigned char* digest_val,
|
||||
size_t digest_len) override;
|
||||
bool GetPeerCertificate(SSLCertificate** cert) const override;
|
||||
StreamState GetState() const override;
|
||||
void Close() override;
|
||||
|
||||
protected:
|
||||
// Internal helper methods
|
||||
// The following method returns 0 on success and a negative
|
||||
// error code on failure. The error code may be either -1 or
|
||||
// from the impl on some other error cases, so it can't really be
|
||||
// interpreted unfortunately.
|
||||
|
||||
// Perform SSL negotiation steps.
|
||||
int ContinueSSL();
|
||||
|
||||
// Error handler helper. signal is given as true for errors in
|
||||
// asynchronous contexts (when an error code was not returned
|
||||
// through some other method), and in that case an SE_CLOSE event is
|
||||
// raised on the stream with the specified error.
|
||||
// A 0 error means a graceful close, otherwise there is not really enough
|
||||
// context to interpret the error code.
|
||||
virtual void Error(const char* context, int err, bool signal);
|
||||
|
||||
// Must be implemented by descendents
|
||||
virtual int BeginSSL() = 0;
|
||||
virtual void Cleanup() = 0;
|
||||
virtual bool GetDigestLength(const std::string& algorithm,
|
||||
size_t* length) = 0;
|
||||
|
||||
enum SSLState {
|
||||
// Before calling one of the StartSSL methods, data flows
|
||||
// in clear text.
|
||||
SSL_NONE,
|
||||
SSL_WAIT, // waiting for the stream to open to start SSL negotiation
|
||||
SSL_CONNECTING, // SSL negotiation in progress
|
||||
SSL_CONNECTED, // SSL stream successfully established
|
||||
SSL_ERROR, // some SSL error occurred, stream is closed
|
||||
SSL_CLOSED // Clean close
|
||||
};
|
||||
|
||||
// MSG_MAX is the maximum generic stream message number.
|
||||
enum { MSG_DTLS_TIMEOUT = MSG_MAX + 1 };
|
||||
|
||||
SSLState state_;
|
||||
SSLRole role_;
|
||||
int ssl_error_code_; // valid when state_ == SSL_ERROR
|
||||
|
||||
// Our key and certificate, mostly useful in peer-to-peer mode.
|
||||
scoped_ptr<SSLIdentity> identity_;
|
||||
// in traditional mode, the server name that the server's certificate
|
||||
// must specify. Empty in peer-to-peer mode.
|
||||
std::string ssl_server_name_;
|
||||
// The peer's certificate. Only used for GetPeerCertificate.
|
||||
scoped_ptr<SSLCertificate> peer_certificate_;
|
||||
|
||||
// The digest of the certificate that the peer must present.
|
||||
Buffer peer_certificate_digest_value_;
|
||||
std::string peer_certificate_digest_algorithm_;
|
||||
|
||||
// Do DTLS or not
|
||||
SSLMode ssl_mode_;
|
||||
|
||||
// Maximum allowed protocol version.
|
||||
SSLProtocolVersion ssl_max_version_;
|
||||
|
||||
private:
|
||||
// Go from state SSL_NONE to either SSL_CONNECTING or SSL_WAIT,
|
||||
// depending on whether the underlying stream is already open or
|
||||
// not. Returns 0 on success and a negative value on error.
|
||||
int StartSSL();
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // WEBRTC_BASE_SSLSTREAMADAPTERHELPER_H_
|
||||
Reference in New Issue
Block a user