A fork of the TLS_cyassl embedded SSL library with certificate validation disabled.

Dependencies:   cyassl-lib

Fork of TLS_cyassl by Francois Berder

Committer:
glbast
Date:
Sat Jan 24 00:30:50 2015 +0000
Revision:
7:5c1e73469291
Parent:
4:86a5029194b4
Disabled SSL certificate checking.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
feb11 0:815067fd66c9 1 #ifndef TLSCONNECTION_H
feb11 0:815067fd66c9 2 #define TLSCONNECTION_H
feb11 0:815067fd66c9 3
feb11 0:815067fd66c9 4 #include "Socket.h"
feb11 0:815067fd66c9 5 #include "Endpoint.h"
feb11 2:63ad554f6ca4 6 #include "bsd_socket.h"
feb11 2:63ad554f6ca4 7 #include "cyassl/ssl.h"
feb11 0:815067fd66c9 8
feb11 4:86a5029194b4 9 class TLSServer;
feb11 4:86a5029194b4 10
feb11 0:815067fd66c9 11 /** This class provides a user-friendly interface for the
feb11 0:815067fd66c9 12 axTLS library.
feb11 0:815067fd66c9 13 */
feb11 0:815067fd66c9 14 class TLSConnection : public Socket, public Endpoint
feb11 0:815067fd66c9 15 {
feb11 4:86a5029194b4 16
feb11 4:86a5029194b4 17 friend class TLSServer;
feb11 0:815067fd66c9 18 public :
feb11 0:815067fd66c9 19
feb11 0:815067fd66c9 20 TLSConnection();
feb11 0:815067fd66c9 21
feb11 0:815067fd66c9 22 /** This function tries to establish a TLS connection
feb11 0:815067fd66c9 23 with the given host.
feb11 0:815067fd66c9 24 It will first try to establish a TCP connection on
feb11 0:815067fd66c9 25 port 443 with the host. Then, it runs the TLS
feb11 0:815067fd66c9 26 handshake protocol.
feb11 0:815067fd66c9 27
feb11 0:815067fd66c9 28 \param host A valid hostname (e.g. "mbed.org")
feb11 0:815067fd66c9 29 \return True if it managed to establish a connection
feb11 0:815067fd66c9 30 with the host. False otherwise.
feb11 0:815067fd66c9 31 */
feb11 0:815067fd66c9 32 bool connect(const char *host);
feb11 0:815067fd66c9 33
feb11 0:815067fd66c9 34 /** Indicates whether a connection is established or not.
feb11 0:815067fd66c9 35
feb11 0:815067fd66c9 36 \return true if a connection is established, otherwise
feb11 0:815067fd66c9 37 returns false.
feb11 0:815067fd66c9 38 */
feb11 0:815067fd66c9 39 bool is_connected(void);
feb11 0:815067fd66c9 40
feb11 0:815067fd66c9 41 /** Sends some data to the host. This method does not return
feb11 0:815067fd66c9 42 until length bytes have been sent.
feb11 0:815067fd66c9 43
feb11 0:815067fd66c9 44 \param data A pointer to some data
feb11 0:815067fd66c9 45 \param length Number of bytes to send
feb11 0:815067fd66c9 46 \return Number of bytes sent, or -1 if an error occured.
feb11 0:815067fd66c9 47 */
feb11 0:815067fd66c9 48 int send_all(char *data, int length);
feb11 0:815067fd66c9 49
feb11 0:815067fd66c9 50 /** Receive some data from the host.
feb11 0:815067fd66c9 51
feb11 0:815067fd66c9 52 \param data
feb11 0:815067fd66c9 53 \param length Maximum number of bytes to receive
feb11 0:815067fd66c9 54 \return Number of bytes read in range 0..length, or -1
feb11 0:815067fd66c9 55 if an error occured.
feb11 0:815067fd66c9 56 */
feb11 0:815067fd66c9 57 int receive(char *data, int length);
feb11 0:815067fd66c9 58
feb11 0:815067fd66c9 59 /** Close the connection.
feb11 0:815067fd66c9 60
feb11 0:815067fd66c9 61 \param shutdown
feb11 0:815067fd66c9 62 \return True if the connection was closed with success,
feb11 0:815067fd66c9 63 false otherwise. If no connection was established,
feb11 0:815067fd66c9 64 returns true immediately.
feb11 0:815067fd66c9 65 */
feb11 0:815067fd66c9 66 bool close(bool shutdown = true);
feb11 0:815067fd66c9 67
feb11 0:815067fd66c9 68 private :
feb11 0:815067fd66c9 69
feb11 0:815067fd66c9 70 bool _is_connected;
feb11 0:815067fd66c9 71
feb11 0:815067fd66c9 72 CYASSL_CTX *_ssl_ctx;
feb11 0:815067fd66c9 73 CYASSL *_ssl;
feb11 0:815067fd66c9 74 };
feb11 0:815067fd66c9 75
feb11 0:815067fd66c9 76 #endif
feb11 0:815067fd66c9 77
feb11 0:815067fd66c9 78