[PD1] Certs done
This commit is contained in:
parent
23584e2901
commit
2c4f1fd2fc
6 changed files with 104 additions and 29 deletions
|
@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ func readMessageContent() string {
|
|||
return scanner.Text()
|
||||
}
|
||||
|
||||
//FIX: Why is this function in the client if it's called by crypto?
|
||||
// It should be called by the client and the result
|
||||
// should then be passed into the crypto library
|
||||
func AskUserPassword() string {
|
||||
fmt.Println("Enter message content (limited to 1000 bytes):")
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
|
@ -22,6 +25,12 @@ func AskUserPassword() string {
|
|||
return scanner.Text()
|
||||
}
|
||||
|
||||
func commandError() {
|
||||
fmt.Println("MSG SERVICE: command error!")
|
||||
showHelp()
|
||||
}
|
||||
|
||||
|
||||
func showHelp() {
|
||||
fmt.Println("Comandos da aplicação cliente:")
|
||||
fmt.Println("-user <FNAME>: Especifica o ficheiro com dados do utilizador. Por omissão, será assumido que esse ficheiro é userdata.p12.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue