[PD2] Relatorio inicio

Co-authored-by: tsousa111 <tiagao2001@hotmail.com>
This commit is contained in:
Afonso Franco 2024-05-31 23:14:06 +01:00
parent 6f8219d991
commit b86992a10a
Signed by: afonso
SSH key fingerprint: SHA256:PQTRDHPH3yALEGtHXnXBp3Orfcn21pK20t0tS1kHg54
10 changed files with 192 additions and 289 deletions

View file

@ -101,15 +101,25 @@ func (k KeyStore) CheckCertTime(cert *x509.Certificate) error {
func (k KeyStore) CheckCertPseudonym(cert *x509.Certificate, pseudonym string) error {
oidMap := ExtractAllOIDValues(cert)
if oidMap["2.5.4.65"] != pseudonym {
return errors.New("Certificate does not belong to the correct pseudonym")
return errors.New("certificate does not belong to the correct pseudonym")
}
return nil
}
// Check if the pseudonym field is set to the correct pseudonym
func (k KeyStore) GetCertPseudonym(cert *x509.Certificate) (string,error){
oidMap := ExtractAllOIDValues(cert)
uid := oidMap["2.5.4.65"]
if uid == "" {
return "",errors.New("certificate does not have a pseudonym field")
}
return uid, nil
}
func (k KeyStore) CheckCertUsage(cert *x509.Certificate, usage string) error {
oidMap := ExtractAllOIDValues(cert)
if oidMap["2.5.4.11"] != usage {
return errors.New("Certificate does not have the correct usage")
return errors.New("certificate does not have the correct usage")
}
return nil
}