[PD2] Made cert checks in cryptoutils

This commit is contained in:
Afonso Franco 2024-05-30 15:48:28 +01:00
parent 69559f41ca
commit 62962a13c7
Signed by: afonso
SSH key fingerprint: SHA256:PQTRDHPH3yALEGtHXnXBp3Orfcn21pK20t0tS1kHg54
9 changed files with 160 additions and 133 deletions

View file

@ -1,7 +1,7 @@
package server
import (
"PD1/internal/protocol"
"PD2/internal/protocol"
"crypto/x509"
"database/sql"
"errors"

View file

@ -1,8 +1,8 @@
package server
import (
"PD1/internal/protocol"
"PD1/internal/utils/cryptoUtils"
"PD2/internal/protocol"
"PD2/internal/utils/cryptoUtils"
"log"
"net/http"
"strconv"
@ -10,29 +10,6 @@ import (
"github.com/gin-gonic/gin"
)
//func clientHandler(connection networking.Connection[protocol.Packet], dataStore DataStore) {
// defer connection.Conn.Close()
//
// //Get certificate sent by user
// clientCert := connection.GetPeerCertificate()
// //Get the OID values
// oidMap := cryptoUtils.ExtractAllOIDValues(clientCert)
// //Check if certificate usage is MSG SERVICE
// usage := oidMap["2.5.4.11"]
// if usage == "" {
// log.Fatalln("User certificate does not have the correct usage")
// }
// //Get the UID of this user
// UID := oidMap["2.5.4.65"]
// if UID == "" {
// log.Fatalln("User certificate does not specify it's PSEUDONYM")
// }
// err := dataStore.storeUserCertIfNotExists(UID, *clientCert)
// if err != nil {
// log.Fatalln(err)
// }
//}
func HandleGetUserCert(c *gin.Context, dataStore DataStore) {
user := c.Param("user")
userCertPacket, err := dataStore.GetUserCertificate(user)