- The first step is installing the server and development libraries. On Ubuntu Linux, at the command prompt type:
- sudo apt-get install -y mysql-server libmysqlclient-dev
At the command prompt, type:
- sudo apt-get update
- sudo apt-get install mysql-server
- sudo mysql_secure_installation utility
- Then just follow the prompts.
- First, run the mysql client:
- sudo mysql -u root –p Enter the root password established in the previous step. This should bring you to the mysql shell. At the shell prompt (mysql>), type:
- CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; Next, grant access rights to the newly created user account. Type:
- GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES;
- At the MySQL client shell prompt, type:
- CREATE DATABASE dogs;
- CREATE TABLE famous_dogs ( id INT UNSIGNED NOT NULL, name VARCHAR(30) NOT NULL, breed VARCHAR(30) NOT NULL );
INSERT INTO famous_dogs ( id, name, breed ) VALUES ( 1, 'Doug', 'Pug' ), (2, 'Toto', 'Cairn Terrier' ), ( 3, 'Beethoven', 'Saint Bernard'), ( 7, 'Beethoven', 'Saint Bernard');
make sure to update the server connection with the credentials of your new datbase line 328 in ssl-server.c
(https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#4-changing-the-window-resolution) (link to ubuntu tutorial)
- in the virtual machine you will have to install the following:
- sudo apt-get install libssl-dev
- sudo apt-get install -y mysql-server libmysqlclient-dev
- sudo apt install gcc
- The source code file for the client, ssl-client.c, and server, ssl-server.c, and a Makefile for both
- You will also need the database to be used with the program
- openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out cert.pem
- This will create two files: a private key contained in the file ‘key.pem’ and a certificate containing a public key in the file ‘cert.pem’. Your server will require both in order to operate properly. Both files must reside in the working directory of your server. The client does not require any such setup to work properly.
- In the command prompt, type:
- make
- this will build both the client and the server
- to remove the executables or clean them up type:
- make clean
It will probably be easiest to open two terminal windows, one for the client and the other for the server.
- ./ssl-server
- or to specify a different port, type:
- ./ssl-server (port number)
This will start the server, listening for incoming TCP connections on the default or specified port. Use a port number greater than 1024, since those below or equal to 1024 are well-known ports reserved for specific applications
- In the second terminal window, invoke the client by typing:
- ./ssl-client localhost
- If the server is on a different machine than the client, you will need to specify that host name in place of localhost
- To specify a specific port type:
- ./ssl-client localhost:4435
- where 4435 is whatever port number you want to specify.