TLSOutputStream

Undocumented

  • Creates a TLS/SSL session for the provided streams.

    This currently works for server side only.

    The provided Certificates are used for encryption.

    When creating an encrypted stream pair, a handshake will automatically be performed. If the handshake fails, a TLSError will be thrown.

    Throws

    A TLSError indicating that the TLS/SSL session could not be created.

    Declaration

    Swift

    open class func CreateStreamPair(fromInputStream inputStream: InputStream, outputStream: OutputStream, certificates: [Certificate]) throws -> (inputStream: TLSInputStream, outputStream: TLSOutputStream)

    Parameters

    inputStream

    Input stream which should be used as an underlying stream to the TLS/SSL input stream. Reads the encrypted data.

    outputStream

    Output stream which should be used as an underlying stream to the TLS/SSL output stream. The encrypted data will be written to it.

    certificates

    Array of certificates for encryption. The first certificate has to contain a private key used for decryption. A private key will automatically be included if the certificate is loaded from a PKCS12-file.

    Return Value

    An encrypted input and output stream.

  • Underlying stream of the encrypted stream.

    Writes data to a source which is TLS/SSL encrypted.

    Data written to the TLSOutputStream will be encrypted and written to this underlying stream.

    Declaration

    Swift

    open let underlyingStream: OutputStream
  • Specifies, if this stream is open and data can be written to it.

    If the stream is closed and a write operation is initiated, an IOError will be thrown.

    Declaration

    Swift

    open var open: Bool
  • Encrypts the provided data and writes it to the underlying stream.

    If the operation fails, an IOError is thrown.

    If an .Interrupted error is thrown, the operation has to be tried again.

    Declaration

    Swift

    open func write(_ data: UnsafeRawPointer, lengthInBytes byteCount: Int) throws

    Parameters

    data

    Data which should be encrypted and written to the stream.

    byteCount

    Number of bytes to encrypt and write.

  • Closes the stream manually and shuts down the underlying stream so no more write calls are possible.

    Subsequent calls to the write-function function will fail.

    This operation also closes the underlying stream.

    Declaration

    Swift

    open func close()