Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need PYTHON language (version 2.7.13) code for project named: \" Virtual Elect

ID: 3834618 • Letter: I

Question

I need PYTHON language (version 2.7.13) code for project named: "Virtual Election Booth"

Ignore the portion in which reading is required

Please view these files and the commentries to see the requirements:

Template: https://1drv.ms/t/s!AsJR_z-_tSxUhF-s08RQVNDqHzCi

Programming project: https://1drv.ms/w/s!AsJR_z-_tSxUhF5w_Deqc_BrnMOg

Every requirement must be fulfilled

Please dont copy paste from internet this is my last question really need it solved. Thanks in advance

Following are the commentries that are required:

1. Step 1: Voter generates a pair of private and public keys – for the purpose of digital signature. Voter uses his private key to sign his request and the public key of the CLA to send his/her message. The message must include the voter’s signed id, say, SSN (request) and the voter’s public key. The public keys of the CLA and CTF may be passed to a voter when he/she starts the session.

2. Step 2: CLA reads the message sent on Step 1 using its private key and, using the voter’ public key, finds the voter’s id . CLA encrypts the validation number using its private key and sends it to the voter. The voter finds the validation number, using the public key of the CLA.

3. Step 3: The CLA sends the list of validation numbers to the CTF using a symmetric key negotiated between CLA and CTF.

4. Step 4: The message from the user to the CTF must be encrypted using the public key of CTF (In the worst case, you can use a symmetric key of CTF).

Explanation / Answer

the python code for virtual Election booth is given booth

certificates - here we are adding function handlers. certs, and keys

ca.crt

-----BEGIN CERTIFICATE-----
MIIDITCCAgmgAwIBAgIJAOtSKnvs3D0yMA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNV
BAMMBW1hamluMB4XDTE2MDQwNjAzMDIzNFoXDTI2MDQwNDAzMDIzNFowEDEOMAwG
A1UEAwwFbWFqaW4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDpyKj7
4e7UuSCFj/pdZoXxXToedIGvhRdGkhhp6WbNnW/OBGyZPtxIgaMBvWkL6aadTL8R
zpBbEZb2rzijb3iHp1ra5CuCtcHUi0O2J1sIpKIzntxExAraPjb9sQPTOtR/1Uyd
aJva5s9oPreATQeubStixIkwGnWqFbfdI9+Zj3BPyt/iMXl9RGU3KER57kfj6Kwz
irVJ9aqee7BjyouMZNveJj4e8egi1a9YCN1+MGS/MxwvmaAqXWiWrnnX4l8G+m66
fE4O9AJwhZs3TqXTep2Ouo0QgIHDR9LaF+JwVrwuYXUC5zJDqZMpaSm24fu5xH03
KuG4iv1YLpQFGWQZAgMBAAGjfjB8MB0GA1UdDgQWBBRr8XeasrZlp3/pq9m2XOKl
VwuPCTBABgNVHSMEOTA3gBRr8XeasrZlp3/pq9m2XOKlVwuPCaEUpBIwEDEOMAwG
A1UEAwwFbWFqaW6CCQDrUip77Nw9MjAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB
BjANBgkqhkiG9w0BAQsFAAOCAQEALaIONOZhHB2SYI9TZ3oVvqdOY4CPa5cRP1zw
y6sLBRgv05jxZHENB4/+hxmbY+LvPREo9VjoYUf+be2svF/00kyMCnLp/OWxIX1V
7Yqy4JUHtk6q02SRMak8Y99MSRAAX7N/orzM+PPJkMmFcibAe4kfGPyaPjaQJZLQ
I8KvkQ5raB+gY6y/BUTi8OauISMopH1oNqg2/YFAMXWpFexhKVYzFCfa6wGBXO6R
wM+U0LEKVBWRhp8Tt5oHrhstSRcz/Dzptvih6CkCLmfoEuEgsGKbylNge5BJ27vh
gXLLbpIpHq7+KoTDksA75OVmh17sbanPTuzQ5awiq9w4wLftkA==
-----END CERTIFICATE-----

localhost.crt

Certificate:
Data:
Version: 3 (0x2)
Serial Number:
0d:c3:0d:c8:78:d0:c2:8c:66:d6:bf:ae:79:c6:c7:8a
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=majin
Validity
Not Before: Apr 6 03:04:45 2016 GMT
Not After : Apr 4 03:04:45 2026 GMT
Subject: CN=localhost
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:f7:60:c4:66:57:f8:d7:c9:22:1f:64:bc:38:a5:
46:56:d8:0d:2f:7e:5e:b8:0c:f9:03:ed:08:d0:8d:
19:0c:4c:73:0e:c0:eb:96:bf:fe:41:19:1b:cc:6a:
c1:b4:8d:b4:43:b7:f2:3c:e5:b6:30:86:a5:37:69:
c7:80:aa:76:8b:b2:1e:08:3b:ec:12:85:0d:b5:93:
f2:f5:eb:02:53:4b:61:d0:ca:75:25:7b:22:e9:4e:
8b:97:4f:73:a9:3e:b1:44:78:6e:33:55:c3:9d:05:
81:e8:89:cb:83:35:2c:af:19:9c:81:97:cf:01:ec:
5e:05:bd:2b:d6:a5:cc:b7:27:11:86:4a:c4:aa:42:
c3:bf:5a:c9:cb:1c:f8:15:66:6c:70:f6:be:5a:b4:
5d:e9:44:38:db:e2:cd:83:2c:61:d8:50:10:8e:2f:
71:26:64:5c:34:3d:5c:5d:d7:9a:e4:a2:0f:d6:e2:
28:f8:68:9b:31:d8:1f:91:97:a4:84:2e:6d:80:06:
eb:24:52:26:f9:8f:42:ef:1c:91:92:79:5b:4a:5b:
d4:83:4a:43:4c:71:4e:d9:db:ad:6c:21:95:fc:6b:
f5:ce:c6:3f:a7:ff:c0:41:90:9a:0f:d0:cf:b0:c1:
37:27:c2:61:2f:78:f4:21:b7:ea:4a:3b:4b:6a:fc:
4d:85
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Subject Key Identifier:
F8:54:FC:16:B5:F8:F5:7F:9B:E0:83:78:83:3D:A4:E8:4E:4A:D5:0F
X509v3 Authority Key Identifier:
keyid:6B:F1:77:9A:B2:B6:65:A7:7F:E9:AB:D9:B6:5C:E2:A5:57:0B:8F:09
DirName:/CN=majin
serial:EB:52:2A:7B:EC:DC:3D:32

X509v3 Extended Key Usage:
TLS Web Server Authentication
X509v3 Key Usage:
Digital Signature, Key Encipherment
Signature Algorithm: sha256WithRSAEncryption
92:64:94:f8:c1:3d:ba:d8:e9:02:c9:c9:16:d2:a9:0d:ff:61:
a2:93:2e:4b:fa:fe:b9:2b:81:94:b3:f8:96:33:2a:56:3e:d3:
30:91:12:55:7d:76:e2:bd:01:fc:5c:9f:9c:59:40:e8:8d:d9:
4e:14:a4:16:6f:5e:34:01:4b:bc:4c:03:17:19:a4:3a:a6:5d:
f3:83:ae:cd:1b:52:65:ca:8c:c7:51:d8:a9:1c:46:21:1b:cf:
92:41:6b:b4:40:f6:53:a8:0c:05:3c:10:5d:83:8f:67:dd:59:
c9:2e:25:f2:43:b1:f3:fb:99:e1:fa:22:2f:10:5d:40:9d:84:
84:dc:05:3a:43:96:a1:c1:0b:f3:6b:fe:ea:c9:31:22:d7:22:
54:92:0d:bc:0c:7b:d5:fa:53:0a:0d:40:83:94:b6:e3:64:f8:
2b:6e:e5:ea:42:e7:24:af:bb:55:6a:33:17:18:ec:c0:08:42:
72:36:41:ab:dd:04:fa:03:91:81:a6:ae:60:80:2c:f5:2b:22:
af:2d:34:f0:93:ad:d1:43:e2:fc:e0:6b:6d:27:c2:e4:fd:9c:
7c:28:ec:b7:f7:07:8a:20:96:33:a8:71:e8:06:76:7b:4c:eb:
69:85:cd:ff:e5:1b:77:c5:de:fb:d6:97:20:76:cf:a6:80:49:
fb:a5:cb:14
-----BEGIN CERTIFICATE-----
MIIDQDCCAiigAwIBAgIQDcMNyHjQwoxm1r+uecbHijANBgkqhkiG9w0BAQsFADAQ
MQ4wDAYDVQQDDAVtYWppbjAeFw0xNjA0MDYwMzA0NDVaFw0yNjA0MDQwMzA0NDVa
MBQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAPdgxGZX+NfJIh9kvDilRlbYDS9+XrgM+QPtCNCNGQxMcw7A65a//kEZ
G8xqwbSNtEO38jzltjCGpTdpx4CqdouyHgg77BKFDbWT8vXrAlNLYdDKdSV7IulO
i5dPc6k+sUR4bjNVw50FgeiJy4M1LK8ZnIGXzwHsXgW9K9alzLcnEYZKxKpCw79a
ycsc+BVmbHD2vlq0XelEONvizYMsYdhQEI4vcSZkXDQ9XF3XmuSiD9biKPhomzHY
H5GXpIQubYAG6yRSJvmPQu8ckZJ5W0pb1INKQ0xxTtnbrWwhlfxr9c7GP6f/wEGQ
mg/Qz7DBNyfCYS949CG36ko7S2r8TYUCAwEAAaOBkTCBjjAJBgNVHRMEAjAAMB0G
A1UdDgQWBBT4VPwWtfj1f5vgg3iDPaToTkrVDzBABgNVHSMEOTA3gBRr8XeasrZl
p3/pq9m2XOKlVwuPCaEUpBIwEDEOMAwGA1UEAwwFbWFqaW6CCQDrUip77Nw9MjAT
BgNVHSUEDDAKBggrBgEFBQcDATALBgNVHQ8EBAMCBaAwDQYJKoZIhvcNAQELBQAD
ggEBAJJklPjBPbrY6QLJyRbSqQ3/YaKTLkv6/rkrgZSz+JYzKlY+0zCRElV9duK9
Afxcn5xZQOiN2U4UpBZvXjQBS7xMAxcZpDqmXfODrs0bUmXKjMdR2KkcRiEbz5JB
a7RA9lOoDAU8EF2Dj2fdWckuJfJDsfP7meH6Ii8QXUCdhITcBTpDlqHBC/Nr/urJ
MSLXIlSSDbwMe9X6UwoNQIOUtuNk+Ctu5epC5ySvu1VqMxcY7MAIQnI2QavdBPoD
kYGmrmCALPUrIq8tNPCTrdFD4vzga20nwuT9nHwo7Lf3B4ogljOocegGdntM62mF
zf/lG3fF3vvWlyB2z6aASfulyxQ=
-----END CERTIFICATE-----


cla - use shorter config

CLA.go
package main

import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"os"
"strconv"
"time"
)

type claConfig struct {
ClaSecret string
CtfSecret string
}

type Cla struct {
Config claConfig
AuthorizedVoters map[string]string // map of voter names to their shared secret with the CLA
voterNumberMap map[string]string // map of voter names to their validation numbers
generator *rand.Zipf
}

type registration struct {
Name string
SharedSecret string
}

type listRequest struct {
SharedSecret string
}

func NewCla(configFileName string) (*Cla, error) {
var cla Cla

voterFile, err := os.Open(configFileName)
if err != nil {
fmt.Fprintln(os.Stderr, "Error opening file", configFileName, ":", err)
return nil, err
}
defer voterFile.Close()

fileBytes, err := ioutil.ReadAll(voterFile)
if err != nil {
fmt.Fprintln(os.Stderr, "Error reading file", configFileName, ":", err)
return nil, err
}
if err = json.Unmarshal(fileBytes, &cla); err != nil {
fmt.Fprintln(os.Stderr, "Error Unmarshalling data:", err)
return nil, err
}

cla.voterNumberMap = make(map[string]string)
for key, _ := range cla.AuthorizedVoters {
cla.voterNumberMap[key] = ""
}

s := rand.NewSource(time.Now().UnixNano())
r := rand.New(s)
cla.generator = rand.NewZipf(r, 1.14, 2402.72, 5000)

return &cla, nil
}

func listHandler(w http.ResponseWriter, r *http.Request, cla *Cla) {
var args listRequest

body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Error unpacking user args.", http.StatusBadRequest)
return
}

err = json.Unmarshal(body, &args)
if err != nil {
fmt.Fprintln(os.Stderr, "CLA list: Error unmarshalling json:", err)
return
}

if args.SharedSecret == "" || cla.Config.CtfSecret != args.SharedSecret {
http.Error(w, "Sent shared secret does not belong to the CTF.", http.StatusForbidden)
return
}

if resp, err := votingDone(cla); err == nil {
err := sendToCtf(w, resp, cla)
if err != nil {
fmt.Fprintf(os.Stderr, "CLA list: Failed to send to CTF:", err)
return
}
} else {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("-1"))
}
}

func sendToCtf(w http.ResponseWriter, toSend []string, cla *Cla) error {
resp := make(map[string]interface{})
resp["sharedSecret"] = cla.Config.ClaSecret
resp["validationNums"] = toSend

respBytes, err := json.Marshal(resp)
if err != nil {
http.Error(w, "Could not marshal validation numbers!", http.StatusNotFound)
return err
}
w.WriteHeader(http.StatusOK)
w.Write(respBytes)
return nil
}

func registrationHandler(w http.ResponseWriter, r *http.Request, cla *Cla) {
var args registration

if _, err := votingDone(cla); err == nil {
fmt.Fprintln(os.Stdin, "Voting is completed")
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("-1"))
return
}

body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Error unpacking user args.", http.StatusBadRequest)
return
}

err = json.Unmarshal(body, &args)
if err != nil {
fmt.Fprintln(os.Stderr, "Error unmarshalling json!", err)
return
}

if args.Name == "" || args.SharedSecret == "" {
http.Error(w, "User did not send either their name or shared secret their request.", http.StatusBadRequest)
return
}

storedSecret := cla.AuthorizedVoters[args.Name]
if storedSecret != args.SharedSecret {
http.Error(w, "User is not an authorized voter.", http.StatusForbidden)
return
}

if cla.voterNumberMap[args.Name] != "" {
http.Error(w, "User has already registered.", http.StatusBadRequest)
return
}

val := generateRandom(cla)
fmt.Println("Using: ", val)
cla.voterNumberMap[args.Name] = val

resp := val
w.WriteHeader(http.StatusOK)
w.Write([]byte(resp))
}

func generateRandom(cla *Cla) string {
newNum := false
var v uint64
for !newNum {
v = cla.generator.Uint64()
if presentInMap(cla, v) {
newNum = false
} else {
newNum = true
}
}
fmt.Println("generated: ", v)
return strconv.FormatUint(v, 10)
}

func presentInMap(cla *Cla, v uint64) bool {
for _, b := range cla.voterNumberMap {
n, err := strconv.ParseUint(b, 10, 64)
if err != nil {
return false
}
if n == v {
return true
}
}
return false
}

func votingDone(cla *Cla) ([]string, error) {
validationNums := make([]string, len(cla.voterNumberMap))
i := 0
for _, b := range cla.voterNumberMap {
if b == "" {
return nil, errors.New("Voting is not done.")
}
validationNums[i] = b
i += 1
}
return validationNums, nil
}

func main() {
cla, err := NewCla("cla/config.json")
if err != nil {
fmt.Fprintf(os.Stderr, "Error: ", err)
return
}

http.HandleFunc("/register", func(w http.ResponseWriter, r *http.Request) {
registrationHandler(w, r, cla)
})
http.HandleFunc("/list", func(w http.ResponseWriter, r *http.Request) {
listHandler(w, r, cla)
})
http.HandleFunc("/ready", func(w http.ResponseWriter, r *http.Request) {
if _, err := votingDone(cla); err == nil {
fmt.Fprintln(os.Stdin, "Ready to vote")
w.WriteHeader(http.StatusOK)
return
} else {
fmt.Fprintln(os.Stdin, "Not ready to vote")
w.WriteHeader(http.StatusUnauthorized)
return
}
})
fmt.Println("Listening and Serving...")
http.ListenAndServeTLS(":9889", "certs/localhost.crt", "keys/localhost.key", nil)
}

config.json

{
"config" : {
"claSecret": "1774",
"ctfSecret": "49832"
},
"authorizedVoters": {
"Dale Cooper": "720947",
"Ed Hurley": "38742"
}
}

tempconfig.json

{
"config" : {
"claSecret": "1774",
"ctfSecret": "49832"
},
"authorizedVoters": {
"Dale Cooper": "720947",
"Harry S. Truman": "2469235",
"Shelly Johnson": "324245",
"Bobby Briggs": "2345254",
"Benjamin Horne": "24355",
"Donna Hayward": "87263952",
"Audrey Horne": "23452953",
"Will Hayward": "984984372",
"Norma Jennings": "75294",
"Hank Jennings": "97327",
"James Hurley": "657483",
"Ed Hurley": "38742"
}
}

static files

style.css

nav {
background-color: lightblue; }

.row {
display: flex;
justify-content: center; }

/*# sourceMappingURL=style.css.map */

style.css.map

{
"version": 3,
"mappings": "AAAA,GAAI;EACH,gBAAgB,EAAE,SAAS;;AAG5B,IAAK;EACJ,OAAO,EAAE,IAAI;EACb,eAAe,EAAE,MAAM",
"sources": ["style.scss"],
"names": [],
"file": "style.css"
}

style.scss

nav {
background-color: lightblue;
}

.row {
display: flex;
justify-content: center;
}

CTF

CTF.go

package main

import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
)

type ctfConfig struct {
ClaSecret string
CtfSecret string
}

type candidate struct {
Name string
VoteCount int
VoterIDs []string // list of validation numbers who have voted for that particular candidate
}

type ListRequest struct {
SharedSecret string
}

type ListResult struct {
SharedSecret string
ValidationNums []string
}

type PublishResp struct {
Candidates []*candidate
}

type voteRequest struct {
Candidate string
ValidationNum string
}

type Ctf struct {
Config ctfConfig
candidates map[string]*candidate // Map of candidate names to candidates
ValidationNums map[string]bool // validation values will be true if used, false otherwise
CandidateNames []string // required to unmarshal json into candidates
}

var client *http.Client

func NewCtf(configFileName string) (*Ctf, error) {
var ctf Ctf

candidateFile, err := os.Open(configFileName)
if err != nil {
fmt.Fprintln(os.Stderr, "Error opening file", configFileName, ":", err)
return nil, err
}
defer candidateFile.Close()

fileBytes, err := ioutil.ReadAll(candidateFile)
if err != nil {
fmt.Fprintln(os.Stderr, "Error reading file", configFileName, ":", err)
return nil, err
}
if err = json.Unmarshal(fileBytes, &ctf); err != nil {
fmt.Fprintln(os.Stderr, "Error Unmarshalling data:", err)
return nil, err
}
// set candidate slice to len of the candidate name list
ctf.candidates = map[string]*candidate{}
ctf.ValidationNums = map[string]bool{}
mapCandidateNames(ctf)

return &ctf, nil
}

func mapCandidateNames(ctf Ctf) Ctf {
for _, val := range ctf.CandidateNames {
// populate map by giving candidate name a non-zero value
ctf.candidates[val] = &candidate{Name: val}
}
ctf.CandidateNames = nil
return ctf
}

func publishHandler(w http.ResponseWriter, r *http.Request, ctf *Ctf) {
// Confirm that voting has ended
if len(ctf.ValidationNums) == 0 {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("Voting still ongoing"))
return
}

for _, val := range ctf.ValidationNums {
if val == false {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("Voting still ongoing"))
return
}
}

// Create JSON response of all candidate objects
var publishResp PublishResp
for _, val := range ctf.candidates {
publishResp.Candidates = append(publishResp.Candidates, val)
}

resp, err := json.Marshal(publishResp)
if err != nil {
http.Error(w, "Could not marshal candidates!", http.StatusNotFound)
return
}
w.WriteHeader(http.StatusOK)
w.Write(resp)
}

func getList(ctf *Ctf) error {
args := ListRequest{
SharedSecret: ctf.Config.CtfSecret,
}
b, err := json.Marshal(args)
if err != nil {
fmt.Fprintln(os.Stderr, "CTF listHandler: Failed to marshal arguments:", err)
return errors.New("Could not marshal args")
}

buf := bytes.NewBuffer(b)
resp, err := client.Post("https://localhost:9889/list", "application/json", buf)
if err != nil {
fmt.Fprintln(os.Stderr, "CTF listHandler: Post failed:", err)
}

if resp.StatusCode != http.StatusOK {
return errors.New("Voting not done")
}

contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Fprintln(os.Stderr, "CTF listHandler: Error opening response:", err)
return errors.New("Could not open response")
}
defer resp.Body.Close()

var listResult ListResult
err = json.Unmarshal(contents, &listResult)
if err != nil {
fmt.Fprintln(os.Stderr, "CTF listHandler: Error unmarshalling json:", err)
}

if listResult.SharedSecret == "" || ctf.Config.ClaSecret != listResult.SharedSecret {
return errors.New("CLA did not send shared secret")
}

for _, validationNum := range listResult.ValidationNums {
ctf.ValidationNums[validationNum] = false
}

return nil
}

func votingHandler(w http.ResponseWriter, r *http.Request, ctf *Ctf) {
var args voteRequest

if len(ctf.ValidationNums) == 0 {
getList(ctf)
}

// check if voting allowed by requesting validation numbers if you don't have them yet
// get voterID from request body
body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Error unpacking user args.", http.StatusBadRequest)
return
}

err = json.Unmarshal(body, &args)
if err != nil {
http.Error(w, "Failed to unmarshal arguments", http.StatusBadRequest)
fmt.Fprintln(os.Stderr, "Error unmarshalling json!", err)
return
}

// will throw error either when voter ID has been used or doesn't exist
if v, ok := ctf.ValidationNums[args.ValidationNum]; v == true || ok == false {
http.Error(w, "Validation number is invalid", http.StatusForbidden)
fmt.Fprintln(os.Stderr, "Validation number", args.ValidationNum)
return
}
// test if submitted candidate exists in candidate list
if _, ok := ctf.candidates[args.Candidate]; ok == false {
http.Error(w, "Candidate does not exist in our directory. Please try again.", http.StatusBadRequest)
return
}
// logic for voting
ctf.ValidationNums[args.ValidationNum] = true
targetCandidate := ctf.candidates[args.Candidate]
targetCandidate.VoteCount++
targetCandidate.VoterIDs = append(targetCandidate.VoterIDs, args.ValidationNum)
}

func main() {
certFile, err := os.Open("certs/ca.crt")
if err != nil {
fmt.Fprintln(os.Stderr, "CTF main: Error opening cert:", err)
return
}
defer certFile.Close()

cert, err := ioutil.ReadAll(certFile)
if err != nil {
fmt.Fprintln(os.Stderr, "CTF main: Error reading cert:", err)
return
}

cp := x509.NewCertPool()
if ok := cp.AppendCertsFromPEM(cert); !ok {
fmt.Fprintln(os.Stderr, "CTF main: Error adding cert:", err)
return
}

cnf := tls.Config{RootCAs: cp}
transport := http.Transport{TLSClientConfig: &cnf}

client = &http.Client{Transport: &transport}

ctf, err := NewCtf("ctf/config.json")
if err != nil {
fmt.Fprintln(os.Stderr, "CTF main: Error creating CTF: ", err)
return
}

http.HandleFunc("/vote", func(w http.ResponseWriter, r *http.Request) {
votingHandler(w, r, ctf)
})
http.HandleFunc("/publish", func(w http.ResponseWriter, r *http.Request) {
publishHandler(w, r, ctf)
})
fmt.Println("Listening and Serving...")
http.ListenAndServeTLS(":9999", "certs/localhost.crt", "keys/localhost.key", nil)
}

config.json

{
"config": {
"claSecret": "1774",
"ctfSecret": "49832"
},
"candidateNames": [
"Benjamin Burroughs",
"William Hun Fondey",
"Samuel C. Lawrison",
"Samuel Lewis Lamberson",
"John Mason",
"Joseph Griffiths Masten",
"David Hervey Li-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD3YMRmV/jXySIf
ZLw4pUZW2A0vfl64DPkD7QjQjRkMTHMOwOuWv/5BGRvMasG0jbRDt/I85bYwhqU3
aceAqnaLsh4IO+wShQ21k/L16wJTS2HQynUleyLpTouXT3OpPrFEeG4zVcOdBYHo
icuDNSyvGZyBl88B7F4FvSvWpcy3JxGGSsSqQsO/WsnLHPgVZmxw9r5atF3pRDjb
4s2DLGHYUBCOL3EmZFw0PVxd15rkog/W4ij4aJsx2B+Rl6SELm2ABuskUib5j0Lv
HJGSeVtKW9SDSkNMcU7Z261sIZX8a/XOxj+n/8BBkJoP0M+wwTcnwmEvePQht+pK
O0tq/E2FAgMBAAECggEAUq7sVkzXJsDaf+W6p7BOR16lYZd6b0gevzot9Q8ELUEs
P+UpmVSI1hdfXD7eicvHUc8cz0/0SlnmxRO9E/tl7iFVumjU6gfA4k0WKy4ms9KB
WjkhWKrEq3iOXb+3p/0FYR5jrxLedBBQMHpGJI/UZJ5J2mL0VO89KevlyDPYrepf
y5lqJRGy78bsnm9OaWblic5C1OVZCjWlFkSGwbkGE2ctgk9IsrIuhqQd6eADQ+Xa
vceSRz8DAFDGYvpQO9thhJTS15+vxvK3RSeRoVi9ThCtV974bvLKMLxgxVRmlF8r
e56sQYWaDYNILdUDH1VMOz9yjsxvUh0DgvPD/1y0jQKBgQD+cLGSb4KjDcwj5wJo
YER+wQAr69dcbe005j1e2kTn/dBJnet7/zScjP5d1b8QtXvgOiBzDnWYZ6NH0voQ
rdUsVNj5ek0nPRxBHkt8y7EqDEKEGIPxoYs/qZHj6xqiNMFBFEtUp3nFK6bXSClN
l/A80IlNobhudvxzWMY5vrJcSwKBgQD45P2N00D2l5E85HGMWFvfWeFdWYJmB10N
2P6gOIC6TSfYr2TwEc0P/ZquweZX3JqLVbhxOIcybulZbK7ELwhmlCKIX0yobZeq
hz0C9H8eYd9at+1uaAwiJnP1fyTBNrTRGEbdxTDk2xze95poZMCfFWURYIkpBN5v
na7QcoM7bwKBgBfFmaGPz4nCYT89dwkfbWbWS1jPKQjWsGHP3Q3+oI94NDych4LH
PjgeKCnGLZq3CgLSC3QUdsItdKDiQkDKrO7+YmM0nP68g+ZFmVHoif3etVw4GiO6
LxNcmWfM8GkVOrUE22DmYMceI/FbKZi5SFW2Og3JvTx822s/cQ22Fl3vAoGAAhmk
jhLPRIVo41OmJaIFPHA8t5XuxL+hKGHBXEa9x1SpVmm8d04fJdhk+r6GHA2vfCeA
A+yPL3zCGVASdXNUJdFwLShotC8gjX7Qo/q+K9p1kQVmSn00RQGADv1AqSS2B+Gl
j29/hx7WModyVRksiusaTDg9UAxLeDOjavzcYJ8CgYEA5XGXwajr6mhWxv3xj2tX
scF551ZS1n4RlXAevXPhn6evtUPUaWcQwtQzohYOMCJcR87WOV6YwEkm6x7vOXWQ
hqciByA83vNYohsQ7R5hO96Arq0z0Ts/Ozp5MeK27WrfN0O70g7kU6+SA10VR6Cd
cu23U7cKkWwwjmJt117emG4=
-----END PRIVATE KEY-----ttle",
"Thomas Clark McLaury",
"William Wilson"
]
}

keys - add function handlers here

localhost.key

-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD3YMRmV/jXySIf
ZLw4pUZW2A0vfl64DPkD7QjQjRkMTHMOwOuWv/5BGRvMasG0jbRDt/I85bYwhqU3
aceAqnaLsh4IO+wShQ21k/L16wJTS2HQynUleyLpTouXT3OpPrFEeG4zVcOdBYHo
icuDNSyvGZyBl88B7F4FvSvWpcy3JxGGSsSqQsO/WsnLHPgVZmxw9r5atF3pRDjb
4s2DLGHYUBCOL3EmZFw0PVxd15rkog/W4ij4aJsx2B+Rl6SELm2ABuskUib5j0Lv
HJGSeVtKW9SDSkNMcU7Z261sIZX8a/XOxj+n/8BBkJoP0M+wwTcnwmEvePQht+pK
O0tq/E2FAgMBAAECggEAUq7sVkzXJsDaf+W6p7BOR16lYZd6b0gevzot9Q8ELUEs
P+UpmVSI1hdfXD7eicvHUc8cz0/0SlnmxRO9E/tl7iFVumjU6gfA4k0WKy4ms9KB
WjkhWKrEq3iOXb+3p/0FYR5jrxLedBBQMHpGJI/UZJ5J2mL0VO89KevlyDPYrepf
y5lqJRGy78bsnm9OaWblic5C1OVZCjWlFkSGwbkGE2ctgk9IsrIuhqQd6eADQ+Xa
vceSRz8DAFDGYvpQO9thhJTS15+vxvK3RSeRoVi9ThCtV974bvLKMLxgxVRmlF8r
e56sQYWaDYNILdUDH1VMOz9yjsxvUh0DgvPD/1y0jQKBgQD+cLGSb4KjDcwj5wJo
YER+wQAr69dcbe005j1e2kTn/dBJnet7/zScjP5d1b8QtXvgOiBzDnWYZ6NH0voQ
rdUsVNj5ek0nPRxBHkt8y7EqDEKEGIPxoYs/qZHj6xqiNMFBFEtUp3nFK6bXSClN
l/A80IlNobhudvxzWMY5vrJcSwKBgQD45P2N00D2l5E85HGMWFvfWeFdWYJmB10N
2P6gOIC6TSfYr2TwEc0P/ZquweZX3JqLVbhxOIcybulZbK7ELwhmlCKIX0yobZeq
hz0C9H8eYd9at+1uaAwiJnP1fyTBNrTRGEbdxTDk2xze95poZMCfFWURYIkpBN5v
na7QcoM7bwKBgBfFmaGPz4nCYT89dwkfbWbWS1jPKQjWsGHP3Q3+oI94NDych4LH
PjgeKCnGLZq3CgLSC3QUdsItdKDiQkDKrO7+YmM0nP68g+ZFmVHoif3etVw4GiO6
LxNcmWfM8GkVOrUE22DmYMceI/FbKZi5SFW2Og3JvTx822s/cQ22Fl3vAoGAAhmk
jhLPRIVo41OmJaIFPHA8t5XuxL+hKGHBXEa9x1SpVmm8d04fJdhk+r6GHA2vfCeA
A+yPL3zCGVASdXNUJdFwLShotC8gjX7Qo/q+K9p1kQVmSn00RQGADv1AqSS2B+Gl
j29/hx7WModyVRksiusaTDg9UAxLeDOjavzcYJ8CgYEA5XGXwajr6mhWxv3xj2tX
scF551ZS1n4RlXAevXPhn6evtUPUaWcQwtQzohYOMCJcR87WOV6YwEkm6x7vOXWQ
hqciByA83vNYohsQ7R5hO96Arq0z0Ts/Ozp5MeK27WrfN0O70g7kU6+SA10VR6Cd
cu23U7cKkWwwjmJt117emG4=
-----END PRIVATE KEY-----

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote