Documentation ¶
Overview ¶
Package x509util includes utility code for working with X.509 certificates from the x509 package.
Index ¶
- Variables
- func CertificateFromPEM(pemBytes string) (*x509.Certificate, error)
- func CertificateToString(cert *x509.Certificate) string
- func Fuzz(data []byte) int
- func NameToString(name pkix.Name) string
- func OidForStandardExtension(oid asn1.ObjectIdentifier) bool
- func OidFromNamedCurve(curve elliptic.Curve) asn1.ObjectIdentifier
- func OidInExtensions(oid asn1.ObjectIdentifier, extensions []pkix.Extension) (int, bool)
Constants ¶
This section is empty.
Variables ¶
var ( OidAttribute = asn1.ObjectIdentifier{2, 5, 4} OidCountry = asn1.ObjectIdentifier{2, 5, 4, 6} OidOrganization = asn1.ObjectIdentifier{2, 5, 4, 10} OidOrganizationalUnit = asn1.ObjectIdentifier{2, 5, 4, 11} OidCommonName = asn1.ObjectIdentifier{2, 5, 4, 3} OidSerialNumber = asn1.ObjectIdentifier{2, 5, 4, 5} OidLocality = asn1.ObjectIdentifier{2, 5, 4, 7} OidProvince = asn1.ObjectIdentifier{2, 5, 4, 8} OidStreetAddress = asn1.ObjectIdentifier{2, 5, 4, 9} OidPostalCode = asn1.ObjectIdentifier{2, 5, 4, 17} OidPseudonym = asn1.ObjectIdentifier{2, 5, 4, 65} OidTitle = asn1.ObjectIdentifier{2, 5, 4, 12} OidDnQualifier = asn1.ObjectIdentifier{2, 5, 4, 46} OidName = asn1.ObjectIdentifier{2, 5, 4, 41} OidSurname = asn1.ObjectIdentifier{2, 5, 4, 4} OidGivenName = asn1.ObjectIdentifier{2, 5, 4, 42} OidInitials = asn1.ObjectIdentifier{2, 5, 4, 43} OidGenerationQualifier = asn1.ObjectIdentifier{2, 5, 4, 44} OidNamedCurveP224 = asn1.ObjectIdentifier{1, 3, 132, 0, 33} OidNamedCurveP256 = asn1.ObjectIdentifier{1, 2, 840, 10045, 3, 1, 7} OidNamedCurveP384 = asn1.ObjectIdentifier{1, 3, 132, 0, 34} OidNamedCurveP521 = asn1.ObjectIdentifier{1, 3, 132, 0, 35} )
//////////////////////////////////// TODO(drysdale): export these constants/functions from x509 and remove this section. Copy of unexported code from x509/x509.go
var ( OidExtensionArc = asn1.ObjectIdentifier{2, 5, 29} // id-ce RFC5280 s4.2.1 OidExtensionSubjectKeyId = asn1.ObjectIdentifier{2, 5, 29, 14} OidExtensionKeyUsage = asn1.ObjectIdentifier{2, 5, 29, 15} OidExtensionExtendedKeyUsage = asn1.ObjectIdentifier{2, 5, 29, 37} OidExtensionAuthorityKeyId = asn1.ObjectIdentifier{2, 5, 29, 35} OidExtensionBasicConstraints = asn1.ObjectIdentifier{2, 5, 29, 19} OidExtensionSubjectAltName = asn1.ObjectIdentifier{2, 5, 29, 17} OidExtensionCertificatePolicies = asn1.ObjectIdentifier{2, 5, 29, 32} OidExtensionNameConstraints = asn1.ObjectIdentifier{2, 5, 29, 30} OidExtensionCRLDistributionPoints = asn1.ObjectIdentifier{2, 5, 29, 31} OidExtensionIssuerAltName = asn1.ObjectIdentifier{2, 5, 29, 18} OidExtensionSubjectDirectoryAttributes = asn1.ObjectIdentifier{2, 5, 29, 9} OidExtensionInhibitAnyPolicy = asn1.ObjectIdentifier{2, 5, 29, 54} OidExtensionPolicyConstraints = asn1.ObjectIdentifier{2, 5, 29, 36} OidExtensionPolicyMappings = asn1.ObjectIdentifier{2, 5, 29, 33} OidExtensionFreshestCRL = asn1.ObjectIdentifier{2, 5, 29, 46} OidExtensionAuthorityInfoAccess = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 1} OidExtensionSubjectInfoAccess = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 11} // RFC 6962 s3.1 OidExtensionCTPoison = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 4, 3} // RFC 6962 s3.3 OidExtensionCTSCT = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 4, 2} )
OID values for X.509 extensions.
Functions ¶
func CertificateFromPEM ¶
func CertificateFromPEM(pemBytes string) (*x509.Certificate, error)
CertificateFromPEM takes a string representing a certificate in PEM format and returns the corresponding x509.Certificate object.
func CertificateToString ¶
func CertificateToString(cert *x509.Certificate) string
CertificateToString generates a string describing the given certificate. The output roughly resembles that from openssl x509 -text.
func Fuzz ¶
Fuzz is a go-fuzz (https://github.com/dvyukov/go-fuzz) entrypoint for fuzzing the parsing of X509 certificates.
func NameToString ¶
NameToString creates a string description of a pkix.Name object.
func OidForStandardExtension ¶
func OidForStandardExtension(oid asn1.ObjectIdentifier) bool
OidForStandardExtension indicates whether oid identifies a standard extension. Standard extensions are listed in RFC 5280 (and other RFCs).
func OidFromNamedCurve ¶
func OidFromNamedCurve(curve elliptic.Curve) asn1.ObjectIdentifier
OidFromNamedCurve returns the OID used to specify the use of the given elliptic curve.
func OidInExtensions ¶
OidInExtensions checks whether the extension identified by oid is present in extensions and returns how many times it occurs together with an indication of whether any of them are marked critical.
Types ¶
This section is empty.