Standard library / crypto/x509
crypto/x509.CertificateRequest.CheckSignature()
Checks proof of possession in a CSR; this does not authorize the names requested. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (c *CertificateRequest) CheckSignature() errorReturn Value
error
Result as described above; check any returned error before use.
Working Example
Example Snippetgo
package main
import ( "crypto/ed25519" "crypto/rand" "crypto/x509" "fmt")
func main() { _, key, e := ed25519.GenerateKey(rand.Reader) check(e) der := must(x509.CreateCertificateRequest(rand.Reader, &x509.CertificateRequest{DNSNames: []string{"example.invalid"}}, key)) fmt.Println(must(x509.ParseCertificateRequest(der)).CheckSignature() == nil)}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}