wrapper of the mbed port of Cyassl. It's based of the work of Ashley Mills
Dependents: TLS_cyassl-Example TLS_cyassl-Example2 HTTPSClientExample2
Fork of TLS_cyassl by
TLSConnection.h
00001 #ifndef TLSCONNECTION_H 00002 #define TLSCONNECTION_H 00003 00004 #include "Socket.h" 00005 #include "Endpoint.h" 00006 #include "bsd_socket.h" 00007 #include "cyassl/ssl.h" 00008 00009 class TLSServer; 00010 00011 /** This class provides a user-friendly interface for the 00012 axTLS library. 00013 */ 00014 class TLSConnection : public Socket, public Endpoint 00015 { 00016 00017 friend class TLSServer; 00018 public : 00019 00020 TLSConnection(); 00021 00022 /** This function tries to establish a TLS connection 00023 with the given host. 00024 It will first try to establish a TCP connection on 00025 port 443 with the host. Then, it runs the TLS 00026 handshake protocol. 00027 00028 \param host A valid hostname (e.g. "mbed.org") 00029 \return True if it managed to establish a connection 00030 with the host. False otherwise. 00031 */ 00032 bool connect(const char *host); 00033 00034 /** Indicates whether a connection is established or not. 00035 00036 \return true if a connection is established, otherwise 00037 returns false. 00038 */ 00039 bool is_connected(void); 00040 00041 /** Sends some data to the host. This method does not return 00042 until length bytes have been sent. 00043 00044 \param data A pointer to some data 00045 \param length Number of bytes to send 00046 \return Number of bytes sent, or -1 if an error occured. 00047 */ 00048 int send_all(char *data, int length); 00049 00050 /** Receive some data from the host. 00051 00052 \param data 00053 \param length Maximum number of bytes to receive 00054 \return Number of bytes read in range 0..length, or -1 00055 if an error occured. 00056 */ 00057 int receive(char *data, int length); 00058 00059 /** Close the connection. 00060 00061 \param shutdown 00062 \return True if the connection was closed with success, 00063 false otherwise. If no connection was established, 00064 returns true immediately. 00065 */ 00066 bool close(bool shutdown = true); 00067 00068 private : 00069 00070 bool _is_connected; 00071 00072 CYASSL_CTX *_ssl_ctx; 00073 CYASSL *_ssl; 00074 }; 00075 00076 #endif 00077 00078
Generated on Tue Jul 12 2022 21:30:48 by 1.7.2