5#include <security/cryptography/x509_certificates/x509_certificate.h>
6#include <security/cryptography/x509_certificates/x509_certificate_collection.h>
7#include <security/cryptography/x509_certificates/x509_chain.h>
8#include <system/array.h>
9#include <system/async_callback.h>
10#include <system/enum_helpers.h>
11#include <system/iasyncresult.h>
12#include <system/io/seekorigin.h>
13#include <system/multicast_delegate.h>
14#include <system/object.h>
15#include <system/shared_ptr.h>
16#include <system/string.h>
18#include <net/secure_protocols/authentificated_stream.h>
19#include <net/secure_protocols/ssl_enum_types.h>
20#include <net/secure_protocols/ssl_policy_errors.h>
22namespace System {
namespace Net {
namespace Details {
23class TlsStreamImplStream;
24class TlsStreamImplSocket;
27namespace System {
namespace Net {
namespace Security {
47 System::MulticastDelegate<System::SharedPtr<System::Security::Cryptography::X509Certificates::X509Certificate>(
53class TlsStreamAsyncResult;
58 friend class TlsStreamAsyncResult;
66 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
68 ASPOSECPP_SHARED_RTTI_INFO_DECL();
193 ASPOSECPP_SHARED_API
void SetLength(int64_t value)
override;
197 ASPOSECPP_SHARED_API
void Flush()
override;
206 ASPOSECPP_SHARED_API int32_t
Read(
const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count)
override;
209 ASPOSECPP_SHARED_API
void Write(
const System::Details::ArrayView<uint8_t>& buffer);
211 ASPOSECPP_SHARED_API
void Write(
const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count)
override;
238 ASPOSECPP_SHARED_API
void Dispose(
bool disposing)
override;
240 ASPOSECPP_SHARED_API
void Close()
override;
247 size_t read(uint8_t buffer[],
size_t size);
251 void write(
const uint8_t buffer[],
size_t size);
A base class for a variety of stream implementations. Objects of this class should only be allocated ...
Definition: stream.h:24
Contains the methods for passing credentials across a stream. Objects of this class should only be al...
Definition: authentificated_stream.h:14
A stream that uses the SSL protocol to authenticate the server and optionally the client.
Definition: ssl_stream.h:57
int32_t get_WriteTimeout() const override
Gets a value, in milliseconds, that determines how long the stream will attempt to write before timin...
virtual void AuthenticateAsClient(String targetHost, System::SharedPtr< System::Security::Cryptography::X509Certificates::X509CertificateCollection > clientCertificates, System::Security::Authentication::SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
Authenticates the client-side of the connection.
void Write(const System::Details::ArrayView< uint8_t > &buffer, int32_t offset, int32_t count) override
Writes the specified subrange of bytes from the specified byte array to the stream.
int64_t Seek(int64_t offset, IO::SeekOrigin origin) override
Sets the position of the stream represented by the current object.
bool get_IsServer() const override
Returns a value that indicates if the local side of the connection is the server.
int32_t Read(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count) override
Reads the specified number of bytes from the stream and writes them to the specified byte array.
virtual System::Security::Authentication::CipherAlgorithmType get_CipherAlgorithm()
Returns the encryption algorithm.
int64_t get_Position() const override
Returns the current position of the stream.
bool get_CanWrite() const override
Determines if the stream is writable.
void set_Position(int64_t value) override
Sets the stream's position.
System::SharedPtr< IAsyncResult > BeginWrite(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t count, AsyncCallback asyncCallback, System::SharedPtr< Object > asyncState) override
Initiates an asynchronous write operation.
void Write(const ArrayPtr< uint8_t > &buffer)
Writes the specified byte array to the stream.
SslStream(System::SharedPtr< IO::Stream > innerStream)
Constructs a new instance.
void Dispose(bool disposing) override
Releases all resources used by the current object and closes the stream.
SslStream(System::SharedPtr< IO::Stream > innerStream, bool leaveInnerStreamOpen)
Constructs a new instance.
bool get_IsSigned() const override
Returns a value that indicates if the data sent using this stream is signed.
void Write(const System::Details::ArrayView< uint8_t > &buffer)
Writes the specified byte array to the stream.
void set_ReadTimeout(int32_t value) override
Sets a value that determines whether the current stream can time out.
SslStream(System::SharedPtr< IO::Stream > innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
Constructs a new instance.
TlsStreamAsyncResult AsyncResultType
Type of AsyncResultType.
Definition: ssl_stream.h:71
virtual System::SharedPtr< System::Security::Cryptography::X509Certificates::X509Certificate > get_RemoteCertificate()
Returns the certificate that is used to authenticate the remote endpoint.
SslStream(System::SharedPtr< IO::Stream > innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
Constructs a new instance.
virtual int32_t get_KeyExchangeStrength()
Returns the strength of the used key exchange algorithm.
virtual int32_t get_HashStrength()
Returns the strength of the used hash algorithm.
virtual System::Security::Authentication::HashAlgorithmType get_HashAlgorithm()
Returns the hash algorithm.
void Flush() override
Clears this stream's buffers and writes all buffered data to the underlying storage.
int32_t EndRead(System::SharedPtr< IAsyncResult > asyncResult) override
Waits until the specified asynchronous read operation completes.
void SetLength(int64_t value) override
Sets the length of the stream represented by the current object.
std::shared_ptr< System::Net::Details::TlsStreamImplSocket > StreamImplementationPtr
Type of pointer to the implementation.
Definition: ssl_stream.h:73
bool get_CanSeek() const override
Determines if the stream supports seeking.
SslStream(System::SharedPtr< IO::Stream > innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
Constructs a new instance.
int32_t Read(const System::Details::ArrayView< uint8_t > &buffer, int32_t offset, int32_t count) override
Reads the specified number of bytes from the stream and writes them to the specified byte array.
bool get_CanRead() const override
Determines if the stream is readable.
void set_WriteTimeout(int32_t value) override
Sets a value, in milliseconds, that determines how long the stream will attempt to read before timing...
bool get_CanTimeout() const override
Gets a value that determines whether the current stream can time out.
System::SharedPtr< IAsyncResult > BeginRead(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t count, AsyncCallback asyncCallback, System::SharedPtr< Object > asyncState) override
Initiates an asynchronous read operation.
void Write(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count) override
Writes the specified subrange of bytes from the specified byte array to the stream.
void Close() override
Closes the stream.
bool get_IsMutuallyAuthenticated() const override
Returns a value that indicates if a server and a client are authenticated.
bool get_IsAuthenticated() const override
Returns a value that indicates if authentication is successfully passed.
int32_t get_ReadTimeout() const override
Gets a value, in milliseconds, that determines how long the stream will attempt to read before timing...
void EndWrite(System::SharedPtr< IAsyncResult > asyncResult) override
Ends an asynchronous write operation. Waits until the specified asynchronous write operation complete...
virtual System::Security::Authentication::SslProtocols get_SslProtocol()
Returns the SSL protocol.
bool get_IsEncrypted() const override
Returns a value that indicates if the data sent using this stream is encrypted.
virtual System::SharedPtr< System::Security::Cryptography::X509Certificates::X509Certificate > get_LocalCertificate()
Returns the certificate that is used to authenticate the local endpoint.
virtual bool get_CheckCertRevocationStatus()
Returns a value that indicates if the certificate revocation list is checked during the certificate v...
int64_t get_Length() const override
Returns the length of the stream in bytes.
virtual void AuthenticateAsClient(String targetHost)
Authenticates the client-side of the connection.
virtual int32_t get_CipherStrength()
Returns the strength of the used encryption algorithm.
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
SeekOrigin
Specifies the reference position in the stream relative to which the position to seek to is specified...
Definition: seekorigin.h:11
Definition: authentificated_stream.h:7
SslPolicyErrors
Enumerates the policy errors of SSL.
Definition: ssl_policy_errors.h:12
System::MulticastDelegate< bool(System::SharedPtr< Object >, System::SharedPtr< System::Security::Cryptography::X509Certificates::X509Certificate >, System::SharedPtr< System::Security::Cryptography::X509Certificates::X509Chain >, SslPolicyErrors)> RemoteCertificateValidationCallback
A user delegate used to verify remote SSL certificate.
Definition: ssl_stream.h:43
EncryptionPolicy
Enumerates the encryption policies.
Definition: ssl_stream.h:31
@ RequireEncryption
Require encryption and never allow a 'Null' cipher.
@ NoEncryption
Allow no encryption and request that a 'Null' cipher be used if the other endpoint can handle a 'Null...
@ AllowNoEncryption
Prefer using full encryption but a 'Null' cipher can be used if the server agrees.
System::MulticastDelegate< System::SharedPtr< System::Security::Cryptography::X509Certificates::X509Certificate >(System::SharedPtr< Object >, String, System::SharedPtr< System::Security::Cryptography::X509Certificates::X509CertificateCollection >, System::SharedPtr< System::Security::Cryptography::X509Certificates::X509Certificate >, System::ArrayPtr< String >)> LocalCertificateSelectionCallback
A user delegate used to select local SSL certificate.
Definition: ssl_stream.h:51
CipherAlgorithmType
Enumerates the cipher algorithms.
Definition: ssl_enum_types.h:28
HashAlgorithmType
Enumerates the hash algorithms.
Definition: ssl_enum_types.h:53
SslProtocols
Enumerates the cryptographic protocols.
Definition: ssl_enum_types.h:9
Definition: db_command.h:9
System::MulticastDelegate< void(SharedPtr< IAsyncResult >)> AsyncCallback
A delegate type that represents a method to be called when asynchronous operation completes.
Definition: async_callback.h:13