ObjFW
Instance Methods | Properties | List of all members
<OFTLSSocket> Protocol Reference

A protocol that should be implemented by 3rd-party libraries implementing TLS. More...

#import <ObjFW/OFTLSSocket.h>

Collaboration diagram for <OFTLSSocket>:
Collaboration graph
[legend]

Instance Methods

(instancetype) - initWithSocket:
 Initializes the TLS socket with the specified TCP socket as its underlying socket. More...
 
(void) - startTLSWithExpectedHost:
 Initiates the TLS handshake. More...
 
(void) - setCertificateFile:forSNIHost:
 Sets the path to the X.509 certificate file to use for the specified SNI host. More...
 
(nullable OFString *) - certificateFileForSNIHost:
 Returns the path of the X.509 certificate file used by the TLS socket for the specified SNI host. More...
 
(void) - setPrivateKeyFile:forSNIHost:
 Sets the path to the PKCS#8 private key file to use for the specified SNI host. More...
 
(nullable OFString *) - privateKeyFileForSNIHost:
 Returns the path of the PKCS#8 private key file used by the TLS socket for the specified SNI host. More...
 
(void) - setPrivateKeyPassphrase:forSNIHost:
 Sets the passphrase to decrypt the PKCS#8 private key file for the specified SNI host. More...
 
(nullable const char *) - privateKeyPassphraseForSNIHost:
 Returns the passphrase to decrypt the PKCS#8 private key file for the specified SNI host. More...
 

Properties

id< OFTLSSocketDelegatedelegate
 The delegate for the TLS socket.
 
OFStringcertificateFile
 The path to the X.509 certificate file to use.
 
OFStringprivateKeyFile
 The path to the PKCS#8 private key file to use.
 
const char * privateKeyPassphrase
 The passphrase to decrypt the PKCS#8 private key file. More...
 
bool verifiesCertificates
 Whether certificates are verified. More...
 

Detailed Description

A protocol that should be implemented by 3rd-party libraries implementing TLS.

Method Documentation

◆ certificateFileForSNIHost:

- (nullable OFString *) certificateFileForSNIHost: (OFString *)  SNIHost

Returns the path of the X.509 certificate file used by the TLS socket for the specified SNI host.

Parameters
SNIHostThe SNI host for which the path of the X.509 certificate file should be returned
Returns
The path of the X.509 certificate file used by the TLS socket for the specified SNI host

◆ initWithSocket:

- (instancetype) initWithSocket: (OFTCPSocket *)  socket

Initializes the TLS socket with the specified TCP socket as its underlying socket.

Parameters
socketThe TCP socket to use as underlying socket

◆ privateKeyFileForSNIHost:

- (nullable OFString *) privateKeyFileForSNIHost: (OFString *)  SNIHost

Returns the path of the PKCS#8 private key file used by the TLS socket for the specified SNI host.

Parameters
SNIHostThe SNI host for which the path of the PKCS#8 private key file should be returned
Returns
The path of the PKCS#8 private key file used by the TLS socket for the specified SNI host

◆ privateKeyPassphraseForSNIHost:

- (nullable const char *) privateKeyPassphraseForSNIHost: (OFString *)  SNIHost

Returns the passphrase to decrypt the PKCS#8 private key file for the specified SNI host.

Warning
You should not copy this to insecure memory which is swappable!
Parameters
SNIHostThe SNI host for which the passphrase to decrypt the PKCS#8 private key file should be returned
Returns
The passphrase to decrypt the PKCS#8 private key file for the specified SNI host

◆ setCertificateFile:forSNIHost:

- (void) setCertificateFile: (OFString *)  certificateFile
forSNIHost: (OFString *)  SNIHost 

Sets the path to the X.509 certificate file to use for the specified SNI host.

Parameters
SNIHostThe SNI host for which the path of the X.509 certificate file should be set
certificateFileThe path to the X.509 certificate file

◆ setPrivateKeyFile:forSNIHost:

- (void) setPrivateKeyFile: (OFString *)  privateKeyFile
forSNIHost: (OFString *)  SNIHost 

Sets the path to the PKCS#8 private key file to use for the specified SNI host.

Parameters
privateKeyFileThe path to the PKCS#8 private key file
SNIHostThe SNI host for which the path to the PKCS#8 private key file should be set

◆ setPrivateKeyPassphrase:forSNIHost:

- (void) setPrivateKeyPassphrase: (const char *)  privateKeyPassphrase
forSNIHost: (OFString *)  SNIHost 

Sets the passphrase to decrypt the PKCS#8 private key file for the specified SNI host.

Warning
You have to ensure that this is in secure memory protected from swapping! This is also the reason why this is not an OFString.
Parameters
privateKeyPassphraseThe passphrase to decrypt the PKCS#8 private key file for the specified SNI host
SNIHostThe SNI host for which the passphrase to decrypt the PKCS#8 private key file should be set

◆ startTLSWithExpectedHost:

- (void) startTLSWithExpectedHost: (nullable OFString *)  host

Initiates the TLS handshake.

Note
This is only useful if you used initWithSocket: to start TLS on a TCP socket which is already connected!
Parameters
hostThe host to expect for certificate verification. May be nil if certificate verification is disabled.

Property Documentation

◆ privateKeyPassphrase

- (const char*) privateKeyPassphrase
readwriteatomic

The passphrase to decrypt the PKCS#8 private key file.

Warning
You have to ensure that this is in secure memory protected from swapping! This is also the reason why this is not an OFString.

◆ verifiesCertificates

- (bool) verifiesCertificates
readwritenonatomicassign

Whether certificates are verified.

The default is enabled.


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