Last active
June 1, 2020 10:54
-
-
Save abohmeed/58b3f0e24e9d0d77e9b5041724068fe8 to your computer and use it in GitHub Desktop.
k8suser gists
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
key, err := rsa.GenerateKey(rand.Reader, 1024) | |
check("The following error occured while creating the RSA key", err) | |
keyDer := x509.MarshalPKCS1PrivateKey(key) | |
commonName := *usernamePtr | |
emailAddress := *emailPtr | |
org := strings.ToUpper(*orgazniationPtr) | |
orgUnit := strings.ToUpper(*orgUnitPtr) | |
city := strings.ToUpper(*cityPtr) | |
state := strings.ToUpper(*provincePtr) | |
country := strings.ToUpper(*countryPtr) | |
subject := pkix.Name{ | |
CommonName: commonName, | |
Country: []string{country}, | |
Locality: []string{city}, | |
Organization: []string{org}, | |
OrganizationalUnit: []string{orgUnit}, | |
Province: []string{state}, | |
} | |
asn1, err := asn1.Marshal(subject.ToRDNSequence()) | |
check("The following error occured while creating the asn1 DNS sequence", err) | |
csrReq := x509.CertificateRequest{ | |
RawSubject: asn1, | |
EmailAddresses: []string{emailAddress}, | |
SignatureAlgorithm: x509.SHA256WithRSA, | |
} | |
bytes, err := x509.CreateCertificateRequest(rand.Reader, &csrReq, key) | |
check("The following error occured while Creating the CSR", err) | |
kubeconfig, err := findKubeConfig() | |
check("The following error occured while getting the Kube Config file", err) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment