[PD1] Certs done

This commit is contained in:
Afonso Franco 2024-04-18 13:06:16 +01:00
parent 23584e2901
commit 2c4f1fd2fc
Signed by: afonso
SSH key fingerprint: SHA256:aiLbdlPwXKJS5wMnghdtod0SPy8imZjlVvCyUX9DJNk
6 changed files with 104 additions and 29 deletions

View file

@ -2,6 +2,7 @@ package client
import (
"PD1/internal/protocol"
"PD1/internal/utils/cryptoUtils"
"PD1/internal/utils/networking"
"flag"
"fmt"
@ -24,16 +25,19 @@ func Run() {
}
uid := flag.Arg(1)
subject := flag.Arg(2)
// Read message content from stdin
messageContent := readMessageContent()
cl := networking.NewClient[protocol.Packet]()
clientCert := cryptoUtils.LoadKeyStore("userdata.p12")
cl := networking.NewClient[protocol.Packet](clientCert)
defer cl.Connection.Conn.Close()
// TODO: getuserinfo client cert
// TODO: ask server for the recieving client's cert
certRequestPacket := protocol.NewRequestUserCertPacket(uid)
cl.Connection.Send(certRequestPacket)
certPacket := cl.Connection.Receive()
// TODO: cipherContent := cryptoUtils.encryptMessageContent()
// TODO: Encrypt message
submitMessage(cl,uid,cipherContent)
case "askqueue":
@ -52,7 +56,7 @@ func Run() {
showHelp()
default:
fmt.Println("Invalid command. Use 'help' for instructions.")
commandError()
}
}