Skip to content

Certificates #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 21, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure the second certificate is not a CA
  • Loading branch information
matteosuppo committed Dec 18, 2015
commit c140d7a7f851de051a6c83101d7951ee036ab028
14 changes: 6 additions & 8 deletions certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ import (
)

var (
host = "localhost"
validFrom = ""
validFor = 365 * 24 * time.Hour * 2 // 2 years
isCA = true
rsaBits = 2048
ecdsaCurve = ""
host = "localhost"
validFrom = ""
validFor = 365 * 24 * time.Hour * 2 // 2 years
rsaBits = 2048
)

func publicKey(priv interface{}) interface{} {
Expand Down Expand Up @@ -123,7 +121,7 @@ func generateSingleCertificate(isCa bool) (*x509.Certificate, error) {
}
}

if isCA {
if isCa {
template.IsCA = true
template.KeyUsage |= x509.KeyUsageCertSign
}
Expand Down Expand Up @@ -197,7 +195,7 @@ func generateCertificates() {
os.Exit(1)
}

derBytes, err = x509.CreateCertificate(rand.Reader, template, caTemplate, publicKey(key), key)
derBytes, err = x509.CreateCertificate(rand.Reader, template, caTemplate, publicKey(key), caKey)

certOut, err = os.Create("cert.pem")
if err != nil {
Expand Down