-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12413 from smarterclayton/x509_uid_extension
Merged by openshift-bot
- Loading branch information
Showing
8 changed files
with
178 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Package extensions defines cryptographic extensions for OpenShift. This | ||
// package contains x509 extension object identifier constants and helpers | ||
// for generating certificates on an OpenShift cluster. | ||
package extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package extensions | ||
|
||
import ( | ||
"encoding/asn1" | ||
) | ||
|
||
// oid is a helper function for concatenating OIDs | ||
func oid(o asn1.ObjectIdentifier, extra ...int) asn1.ObjectIdentifier { | ||
return asn1.ObjectIdentifier(append(append([]int{}, o...), extra...)) | ||
} | ||
|
||
var ( | ||
// RedHatOID is the IANA assigned ObjectIdentifier for Red Hat Inc. | ||
RedHatOID = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 2312} | ||
// OpenShiftOID is the Red Hat assigned OID arc for OpenShift. | ||
OpenShiftOID = oid(RedHatOID, 17) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package extensions | ||
|
||
import ( | ||
"crypto/x509" | ||
"crypto/x509/pkix" | ||
"encoding/asn1" | ||
|
||
kapi "k8s.io/kubernetes/pkg/api" | ||
|
||
"github.com/openshift/origin/pkg/cmd/server/crypto" | ||
) | ||
|
||
var ( | ||
// OpenShiftServerSigningOID is the OpenShift assigned OID arc for certificates signed by the OpenShift server. | ||
OpenShiftServerSigningOID = oid(OpenShiftOID, 100) | ||
// OpenShiftServerSigningServiceOID describes the IANA arc for extensions to server certificates generated by the | ||
// OpenShift service signing mechanism. All elements in this arc should only be used when signing server certificates | ||
// for use under a service. | ||
OpenShiftServerSigningServiceOID = oid(OpenShiftServerSigningOID, 2) | ||
// OpenShiftServerSigningServiceUIDOID is an x509 extension that is applied to server certificates generated for services | ||
// representing the UID of the service this certificate was generated for. This value is not guaranteed to match the | ||
// current service UID if the certificates are in the process of being rotated out. The value MUST be an ASN.1 | ||
// PrintableString or UTF8String. | ||
OpenShiftServerSigningServiceUIDOID = oid(OpenShiftServerSigningServiceOID, 1) | ||
) | ||
|
||
// ServiceServerCertificateExtension returns a CertificateExtensionFunc that will add the | ||
// service UID as an x509 v3 extension to the server certificate. | ||
func ServiceServerCertificateExtension(svc *kapi.Service) crypto.CertificateExtensionFunc { | ||
return func(cert *x509.Certificate) error { | ||
uid, err := asn1.Marshal(svc.UID) | ||
if err != nil { | ||
return err | ||
} | ||
cert.ExtraExtensions = append(cert.ExtraExtensions, pkix.Extension{ | ||
Id: OpenShiftServerSigningServiceUIDOID, | ||
Critical: false, | ||
Value: uid, | ||
}) | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters