It looks like adding the x509.OID type and associated fields to the 
x509.Certificate struct breaks the ability to gob-encode the certificate.  
The following test program succeeds on go 1.21.6 and fails on 1.22.0:

package main

import (
        "log"
        "bytes"
        "encoding/gob"
        "crypto/x509"
        "crypto/rsa"
        "crypto/dsa"
        "crypto/ecdh"
        "crypto/ecdsa"
        "crypto/ed25519"
)

func init() {
        gob.Register(rsa.PrivateKey{})
        gob.Register(dsa.PrivateKey{})
        gob.Register(ecdh.PrivateKey{})
        gob.Register(ecdsa.PrivateKey{})
        gob.Register(ed25519.PrivateKey{})
        gob.Register(rsa.PublicKey{})
        gob.Register(dsa.PublicKey{})
        gob.Register(ecdh.PublicKey{})
        gob.Register(ecdsa.PublicKey{})
        gob.Register(ed25519.PublicKey{})
}

func main() {
        c := &x509.Certificate{}
        b := &bytes.Buffer{}

        enc := gob.NewEncoder(b)
        if err := enc.Encode(c); err != nil {
                log.Printf("Failed to gob encode empty x.509 cert: %v", err)
        } else {
                log.Printf("Encoded empty x.509 cert")
        }
}

It looks like the x509.OID type is not able to be marshalled by gob since 
it is a struct that contains a single unexported field, and it doesn't 
implement text or binary marshalling.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2a335349-3c9b-45b5-94d5-fb4f8c7edabcn%40googlegroups.com.

Reply via email to