aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/crypto
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-11-29 23:02:54 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-11-29 23:02:54 +0000
commitb740cb6335fd36e5847f2abd3c890b7f14d1ef30 (patch)
tree3cbc69464b9e65b6abf2f6adbda2845f1577b756 /libgo/go/crypto
parentcebc182b78fd3be5396fb772f3b12a9096fc73ab (diff)
downloadgcc-b740cb6335fd36e5847f2abd3c890b7f14d1ef30.zip
gcc-b740cb6335fd36e5847f2abd3c890b7f14d1ef30.tar.gz
gcc-b740cb6335fd36e5847f2abd3c890b7f14d1ef30.tar.bz2
libgo: update to weekly.2011-10-25
Changes were mainly straightforward to merge. From-SVN: r181824
Diffstat (limited to 'libgo/go/crypto')
-rw-r--r--libgo/go/crypto/x509/x509.go4
-rw-r--r--libgo/go/crypto/x509/x509_test.go13
2 files changed, 13 insertions, 4 deletions
diff --git a/libgo/go/crypto/x509/x509.go b/libgo/go/crypto/x509/x509.go
index 4b8ecc5..73b32e7 100644
--- a/libgo/go/crypto/x509/x509.go
+++ b/libgo/go/crypto/x509/x509.go
@@ -928,11 +928,11 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.P
return
}
- asn1Issuer, err := asn1.Marshal(parent.Issuer.ToRDNSequence())
+ asn1Issuer, err := asn1.Marshal(parent.Subject.ToRDNSequence())
if err != nil {
return
}
- asn1Subject, err := asn1.Marshal(parent.Subject.ToRDNSequence())
+ asn1Subject, err := asn1.Marshal(template.Subject.ToRDNSequence())
if err != nil {
return
}
diff --git a/libgo/go/crypto/x509/x509_test.go b/libgo/go/crypto/x509/x509_test.go
index dbc5273..d113f85 100644
--- a/libgo/go/crypto/x509/x509_test.go
+++ b/libgo/go/crypto/x509/x509_test.go
@@ -6,8 +6,8 @@ package x509
import (
"asn1"
- "bytes"
"big"
+ "bytes"
"crypto/dsa"
"crypto/rand"
"crypto/rsa"
@@ -243,10 +243,11 @@ func TestCreateSelfSignedCertificate(t *testing.T) {
return
}
+ commonName := "test.example.com"
template := Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{
- CommonName: "test.example.com",
+ CommonName: commonName,
Organization: []string{"Acme Co"},
},
NotBefore: time.SecondsToUTC(1000),
@@ -283,6 +284,14 @@ func TestCreateSelfSignedCertificate(t *testing.T) {
t.Errorf("Failed to parse name constraints: %#v", cert.PermittedDNSDomains)
}
+ if cert.Subject.CommonName != commonName {
+ t.Errorf("Subject wasn't correctly copied from the template. Got %s, want %s", cert.Subject.CommonName, commonName)
+ }
+
+ if cert.Issuer.CommonName != commonName {
+ t.Errorf("Issuer wasn't correctly copied from the template. Got %s, want %s", cert.Issuer.CommonName, commonName)
+ }
+
err = cert.CheckSignatureFrom(cert)
if err != nil {
t.Errorf("Signature verification failed: %s", err)