Skip to content

Server communication

Johannes Ernstsen edited this page Mar 22, 2019 · 15 revisions

The system contains multiple servers, which all have APIs. These APIs can be found on this page. Communication is through REST.

SSL

To secure the connection between the servers, and the clients casting votes, we implemented HTTPS SSL connections. This is done using a ServerConnector with a HTTPS SslContextFactory, and a HttpConfiguration. We've also created a self-signed certificate by running keytool -keystore -alias evhe -keyalg RSA -keysize 2048, outputting a keystore.jks file, which we store in /certs/.

In order for testing on localhost, we added the following code

HttpsURLConnection.setDefaultHostnameVerifier((hostname, sslSession) -> hostname.equals("localhost"))

For our client and public server to be able to talk to the key server, they use an SSLContext with a TrustManagerFactory loading our certificate. The SSLContext is then added to the JerseyClientBuilder.

API

Key Server

Request Public key

Request that requests the key-server to send a public-key to be used in the voting session.

key value
Type GET
Path /publicKey
Params None
Resp Hexadecimal public key
Code 200/500

GetResult

Request that prompts the server for a plaintext of the given ciphertext

key value
Type POST
Path /result
Params None
Body Encrypted sum of all votes
Resp Sum of all votes
Code 200/500

Public Server

Request Public key

Request that requests the public server to send a public-key to be used in the voting session.

404 is returned if the server does not yet have a public key in store

key value
Type GET
Path /publicKey
Params None
Resp Hexadecimal public key
Code 200/404/500

Vote

Request that posts an encrypted vote to the public server.

Returns 403: Permission Denied if vote has already been cast

key value
Type POST
Path /vote
Params None
Body Tuple: (ID, Encrypted vote)
Resp Empty
Code 204/403/500

Get voter identities

key value
Type GET
Path /generateVoters
Params None
Resp newline seperated ids(HTML)
Code 200/500

Get result

key value
Type GET
Path /result
Params None
Resp result as HTML
Code 200/500

Iteration 2

For iteration two the API needed to be updated to change the nature of the public server to become that of a bulletin board.

For the vote verification part of the iteration to work the signature of votes will also need to be updated

For this the following API entries were added to PublicServer:

Get votes

key value
Type GET
Path /getVotes
Params None
Resp List of votes
Code 200/404/500

Vote

key value
Type POST
Path /vote
Params None
Body Tuple:(ID, Enc(vote), proof)
Resp Empty
Code 204/403/500

Where proof is a proof that the vote is either 0 or 1.