Skip to content

crypto/x509/pkix: Name.String() follows obsolete RFC #27401

@pjbgtnj

Description

@pjbgtnj

Please answer these questions before submitting your issue. Thanks!

The format of a certificate Subject (or Issuer) when made into a String is following RFC 2253 (obsolete) instead of 4514. Using the same format as given by "openssl x509 -in cert.pem -text -noout" would be much more useful.

What version of Go are you using (go version)?

1.11

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

linux, amd64

What did you do?

Print the issuer (or subject) dn from an x509 certificat

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

import (
"crypto/x509"
"encoding/pem"
"fmt"
)

func main() {
rawPem :=
-----BEGIN CERTIFICATE----- MIIDizCCAnOgAwIBAgIJAOnd3oVtvRW4MA0GCSqGSIb3DQEBCwUAMFwxFzAVBgNV BAMMDnNvbWVkb21haW4uY29tMRcwFQYDVQQKDA5NeSBDb3Jwb3JhdGlvbjETMBEG A1UECwwKT3JnIFVuaXQgMTETMBEGA1UECwwKT3JnIFVuaXQgMjAeFw0xODA4MzEw MTE5MzBaFw0xODA5MzAwMTE5MzBaMFwxFzAVBgNVBAMMDnNvbWVkb21haW4uY29t MRcwFQYDVQQKDA5NeSBDb3Jwb3JhdGlvbjETMBEGA1UECwwKT3JnIFVuaXQgMTET MBEGA1UECwwKT3JnIFVuaXQgMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC ggEBAKCmoAGdRmzfb807ZQw1NAIhdqeKeNi7niZeYrzocBavzHd/6WfsdF/FqLjB NH6BRwB7j86O7hyETJcfcXnrJGsKcbBTspMjDBHp+XDvoWElfx7W7A1F/ZI51MjK OZkWFgNl2bGJIvFNAe25fQTlRtjW6/OC+SxXssaHufKjTJDqGo3YlEOvVWcMGXiS cJBOnDTDABt6caAf9QbPFS6SI7Qq7East5xRATkY3Hz9CM5EU5x6j+frO30gvsQs eyIRU6vHgKEsnO90hxF0TQtXiI4IrYL/ofa6J7Ncpnerj0/0+6Kw2qgV5qse8/BS H0AUXwNp9gm/WMDI0ehiwLDUFIcCAwEAAaNQME4wHQYDVR0OBBYEFGl1dJ7BFREN NK2BF5NDqimHP9zfMB8GA1UdIwQYMBaAFGl1dJ7BFRENNK2BF5NDqimHP9zfMAwG A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBADjJ34L0Rrz+suetYK+NKiXG 8dQcbMOYxSFg8HjNB7ZtL97lRpeRwoPx4IjpcbuYtvKdxVuDea0753VNe7Q3qowt 0k3IEgzVTN5fTInFisLQG9jCfkhHByeNrOgLs6qrk8O+6SqMcOgVuNmMzZDhlXj+ 9drp70xZtLLUN9zFbFESlFoq8GBd4CeerMNn/eU+ukFI/outLU+0+y9lpXwrHglk 9VGJtB40NiSNfhb8MqNTVgPnyEDTOHEStbYddmDTFXtuvGe5b0+j5DBQao87JPr/ rwUus39HqmFbSZtkxEjFI71Dh4Q0HnoDHM8+GyJohYxqk81fQlJJGW0M2XEWT3g= -----END CERTIFICATE-----
pemBlock, _ := pem.Decode([]byte(rawPem))
cert, _ := x509.ParseCertificate(pemBlock.Bytes)
fmt.Printf("%s\n", cert.Issuer)
}

What did you expect to see?

CN=somedomain.com, O=My Corporation, OU=Org Unit 1, OU=Org Unit 2

What did you see instead?

CN=somedomain.com,OU=Org Unit 1+OU=Org Unit 2,O=My Corporation

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions