Skip to main content

Posts

Showing posts with the label C Programming

Client and Server Using OpenSSL Library In C Programmaing

In this example code, we will create a secure connection between client and server using the TLS1.2 protocol. In this communication, the client sends an XML request to the server which contains the username and password. Then, the server will verifies the XML request, if it is valid then it sends a proper XML response to the client either give a message of Invalid Request. How to install OpenSSL Lib: sudo apt-get install libssl–dev Generate your own certificate : openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem Example Client code for TLS1.2 communication #include <stdio.h> #include <errno.h> #include <unistd.h> #include <malloc.h> #include <string.h> #include <sys/socket.h> #include <resolv.h> #include <netdb.h> #include <openssl/ssl.h> #include <openssl/err.h> #define FAIL -1 #include <stdio.h> #include <errno.h> #include <unistd.h> #include <malloc.h...