-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for X.509 codegen and parsing
- Loading branch information
1 parent
5d9be14
commit 0acf752
Showing
3 changed files
with
109 additions
and
4 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,30 @@ | ||
package examples | ||
|
||
import ( | ||
"encoding/asn1" | ||
"encoding/pem" | ||
"io/ioutil" | ||
"testing" | ||
) | ||
|
||
// Has to use big.Int integers due to SerialNumber size. | ||
|
||
//go:generate go run ../cmd/asn1go/main.go -default-integer-repr big.Int -package examples rfc5280.asn1 rfc5280_generated.go | ||
|
||
func TestX509Declarations(t *testing.T) { | ||
var _ Certificate | ||
var _ CertificateList | ||
} | ||
|
||
func TestX509Parsing(t *testing.T) { | ||
data, err := ioutil.ReadFile("testdata/_.google.crt") | ||
if err != nil { | ||
t.Fatalf("Failed to read crt: %v", err) | ||
} | ||
block, _ := pem.Decode(data) | ||
var cert Certificate | ||
if _, err := asn1.Unmarshal(block.Bytes, &cert); err != nil { | ||
t.Fatalf("Failed to parse certificate: %v", err) | ||
} | ||
t.Logf("%+v", cert) | ||
} |
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,77 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIN7TCCDNWgAwIBAgIQJj7Rgvf7Iw4K092uo999iDANBgkqhkiG9w0BAQsFADBG | ||
MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlc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