# PSSLChannel Class Reference

This class will start a secure SSL based channel. More...

`#include <pssl.h>`

Inheritance diagram for PSSLChannel:

List of all members.

## Public Types

| VerifyNone
| VerifyPeer
| VerifyPeerMandatory
enum | VerifyMode { VerifyNone, VerifyPeer, VerifyPeerMandatory }

## Public Member Functions

| PSSLChannel (PSSLContext *context=NULL, PBoolean autoDeleteContext=false)
| Create a new channel given the context.
| PSSLChannel (PSSLContext &context)
| ~PSSLChannel ()
| Close and clear the SSL channel.
virtual PBoolean | Read (void *buf, PINDEX len)
| Low level read from the channel.
virtual PBoolean | Write (const void *buf, PINDEX len)
| Low level write to the channel.
virtual PBoolean | Close ()
| Close the channel.
virtual PBoolean | Shutdown (ShutdownValue)
| Close one or both of the data streams associated with a channel.
virtual PString | GetErrorText (ErrorGroup group=NumErrorGroups) const
| Get error message description.
virtual PBoolean | ConvertOSError (int error, ErrorGroup group=LastGeneralError)
PBoolean | Accept ()
| Accept a new inbound connection (server).
PBoolean | Accept (PChannel &channel)
| Accept a new inbound connection (server).
PBoolean | Accept (PChannel *channel, PBoolean autoDelete=true)
| Accept a new inbound connection (server).
PBoolean | Connect ()
| Connect to remote server.
PBoolean | Connect (PChannel &channel)
| Connect to remote server.
PBoolean | Connect (PChannel *channel, PBoolean autoDelete=true)
| Connect to remote server.
PBoolean | UseCertificate (const PSSLCertificate &certificate)
| Use the certificate specified.
PBoolean | UsePrivateKey (const PSSLPrivateKey &key)
| Use the private key file specified.
void | SetVerifyMode (VerifyMode mode)
PSSLContext * | GetContext () const
virtual PBoolean | RawSSLRead (void *buf, PINDEX &len)

## Protected Member Functions

virtual PBoolean | OnOpen ()
| This callback is executed when the Open() function is called with open channels.

## Protected Attributes

PSSLContext * | context
PBoolean | autoDeleteContext
ssl_st * | ssl

## Detailed Description

This class will start a secure SSL based channel.

## Member Enumeration Documentation

enum PSSLChannel::VerifyMode

Enumerator:

  VerifyNone |
  VerifyPeer |
  VerifyPeerMandatory |

## Constructor & Destructor Documentation

PSSLChannel::PSSLChannel | ( | PSSLContext * | context = `NULL`,
|  | PBoolean | autoDeleteContext = `false` |
| ) |  |  |

Create a new channel given the context.

If no context is given a default one is created.

Parameters:

  context | Context for SSL channel
  autoDeleteContext | Flag for context to be automatically deleted.

PSSLChannel::PSSLChannel | ( | PSSLContext & | context | ) |

Parameters:

  context | Context for SSL channel

PSSLChannel::~PSSLChannel | ( |  | ) |

Close and clear the SSL channel.

## Member Function Documentation

PBoolean PSSLChannel::Accept | ( | PChannel * | channel,
|  | PBoolean | autoDelete = `true` |
| ) |  |  |

Accept a new inbound connection (server).

Parameters:

  channel | Channel to attach to.
  autoDelete | Flag for if channel should be automatically deleted.

PBoolean PSSLChannel::Accept | ( | PChannel & | channel | ) |

Accept a new inbound connection (server).

Parameters:

  channel | Channel to attach to.

PBoolean PSSLChannel::Accept | ( |  | ) |

Accept a new inbound connection (server).

This version expects that the indirect channel has already been opened using Open() beforehand.

virtual PBoolean PSSLChannel::Close | ( |  | ) | `[virtual]`

Close the channel.

This will detach itself from the read and write channels and delete both of them if they are auto delete.

Returns:
  true if the channel is closed.

Reimplemented from PIndirectChannel.

PBoolean PSSLChannel::Connect | ( | PChannel * | channel,
|  | PBoolean | autoDelete = `true` |
| ) |  |  |

Connect to remote server.

Parameters:

  channel | Channel to attach to.
  autoDelete | Flag for if channel should be automatically deleted.

PBoolean PSSLChannel::Connect | ( | PChannel & | channel | ) |

Connect to remote server.

Parameters:

  channel | Channel to attach to.

PBoolean PSSLChannel::Connect | ( |  | ) |

Connect to remote server.

This version expects that the indirect channel has already been opened using Open() beforehand.

virtual PBoolean PSSLChannel::ConvertOSError | ( | int | error,
|  | ErrorGroup | group = `LastGeneralError` |
| ) |  |  | `[virtual]`

PSSLContext* PSSLChannel::GetContext | ( |  | ) | const`[inline]`

virtual PString PSSLChannel::GetErrorText | ( | ErrorGroup | group = `NumErrorGroups` | ) | const`[virtual]`

Get error message description.

Return a string indicating the error message that may be displayed to the user. The error for the last I/O operation in this object is used.

Returns:
  Operating System error description string.

Reimplemented from PIndirectChannel.

virtual PBoolean PSSLChannel::OnOpen | ( |  | ) | `[protected, virtual]`

This callback is executed when the Open() function is called with open channels.

It may be used by descendent channels to do any handshaking required by the protocol that channel embodies.

The default behaviour "connects" the channel to the OpenSSL library.

Returns:
  Returns true if the protocol handshaking is successful.

Reimplemented from PIndirectChannel.

virtual PBoolean PSSLChannel::RawSSLRead | ( | void * | buf,
|  | PINDEX & | len |
| ) |  |  | `[virtual]`

virtual PBoolean PSSLChannel::Read | ( | void * | buf,
|  | PINDEX | len |
| ) |  |  | `[virtual]`

Low level read from the channel.

This function may block until the requested number of characters were read or the read timeout was reached. The GetLastReadCount() function returns the actual number of bytes read.

This will use the `readChannel` pointer to actually do the read. If `readChannel` is null the this asserts.

The GetErrorCode() function should be consulted after Read() returns false to determine what caused the failure.

Returns:
  true indicates that at least one character was read from the channel. false means no bytes were read due to timeout or some other I/O error.

Reimplemented from PIndirectChannel.

void PSSLChannel::SetVerifyMode | ( | VerifyMode | mode | ) |

virtual PBoolean PSSLChannel::Shutdown | ( | ShutdownValue |  | ) | `[inline, virtual]`

Close one or both of the data streams associated with a channel.

The behavour here is to pass the shutdown on to its read and write channels.

Returns:
  true if the shutdown was successfully performed.

Reimplemented from PIndirectChannel.

PBoolean PSSLChannel::UseCertificate | ( | const PSSLCertificate & | certificate | ) |

Use the certificate specified.

PBoolean PSSLChannel::UsePrivateKey | ( | const PSSLPrivateKey & | key | ) |

Use the private key file specified.

virtual PBoolean PSSLChannel::Write | ( | const void * | buf,
|  | PINDEX | len |
| ) |  |  | `[virtual]`

Low level write to the channel.

This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.

This will use the `writeChannel` pointer to actually do the write. If `writeChannel` is null the this asserts.

The GetErrorCode() function should be consulted after Write() returns false to determine what caused the failure.

Returns:
  true if at least len bytes were written to the channel.

Reimplemented from PIndirectChannel.

## Member Data Documentation

PBoolean PSSLChannel::autoDeleteContext `[protected]`

PSSLContext* PSSLChannel::context `[protected]`

ssl_st* PSSLChannel::ssl `[protected]`

The documentation for this class was generated from the following file:

- pssl.h