Using this lib you will be capable of extract the subject DN following RFC 4514 definitions, with aditional translation of OIDs to names specified by the OpenBanking Brasil security specs.
The implementation follows the rules at August 26, 2021.
Version | Date (aprox.) of spec |
---|---|
initial | August 26, 2021 |
go get github.com/esachser/obbsubjectextractor
go get github.com/esachser/obbsubjectextractor/cmd/obbsubextractor
Example from the cmd folder;
import (
"crypto/x509"
"encoding/pem"
"flag"
"fmt"
"os"
"path/filepath"
"github.com/esachser/obbsubjectextractor"
)
func main() {
filename := os.Args[1]
pemFile, _ := os.ReadFile(filename)
pemBlock, _ := pem.Decode(pemFile)
cert, _ := x509.ParseCertificate(pemBlock.Bytes)
subjectDN, err := obbsubjectextractor.ExtractSubject(cert)
fmt.Println(subjectDN, err)
}
obbsubextractor <path-to-pem>