Run gofmt
Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
This commit is contained in:
parent
38b9c920eb
commit
acc6781f29
5
asn1.go
5
asn1.go
|
@ -10,10 +10,10 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,4 +75,3 @@ func decodeASN1String (value *asn1.RawValue) (string, error) {
|
||||||
}
|
}
|
||||||
return "", errors.New("Not a string")
|
return "", errors.New("Not a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
76
asn1time.go
76
asn1time.go
|
@ -10,11 +10,11 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"strconv"
|
|
||||||
"errors"
|
|
||||||
"unicode"
|
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
|
"errors"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isDigit(b byte) bool {
|
func isDigit(b byte) bool {
|
||||||
|
@ -36,19 +36,29 @@ func parseUTCTime (bytes []byte) (time.Time, error) {
|
||||||
return time.Time{}, errors.New("UTCTime is too short")
|
return time.Time{}, errors.New("UTCTime is too short")
|
||||||
}
|
}
|
||||||
year, err = bytesToInt(bytes[0:2])
|
year, err = bytesToInt(bytes[0:2])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
month, err = bytesToInt(bytes[2:4])
|
month, err = bytesToInt(bytes[2:4])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
day, err = bytesToInt(bytes[4:6])
|
day, err = bytesToInt(bytes[4:6])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
hour, err = bytesToInt(bytes[6:8])
|
hour, err = bytesToInt(bytes[6:8])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
min, err = bytesToInt(bytes[8:10])
|
min, err = bytesToInt(bytes[8:10])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
bytes = bytes[10:]
|
bytes = bytes[10:]
|
||||||
|
|
||||||
|
@ -72,10 +82,14 @@ func parseUTCTime (bytes []byte) (time.Time, error) {
|
||||||
return time.Time{}, errors.New("UTCTime positive timezone offset is too short")
|
return time.Time{}, errors.New("UTCTime positive timezone offset is too short")
|
||||||
}
|
}
|
||||||
tzHour, err := bytesToInt(bytes[1:3])
|
tzHour, err := bytesToInt(bytes[1:3])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tzMin, err := bytesToInt(bytes[3:5])
|
tzMin, err := bytesToInt(bytes[3:5])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tz = time.FixedZone("", tzHour*3600+tzMin*60)
|
tz = time.FixedZone("", tzHour*3600+tzMin*60)
|
||||||
bytes = bytes[5:]
|
bytes = bytes[5:]
|
||||||
|
@ -85,10 +99,14 @@ func parseUTCTime (bytes []byte) (time.Time, error) {
|
||||||
return time.Time{}, errors.New("UTCTime negative timezone offset is too short")
|
return time.Time{}, errors.New("UTCTime negative timezone offset is too short")
|
||||||
}
|
}
|
||||||
tzHour, err := bytesToInt(bytes[1:3])
|
tzHour, err := bytesToInt(bytes[1:3])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tzMin, err := bytesToInt(bytes[3:5])
|
tzMin, err := bytesToInt(bytes[3:5])
|
||||||
if err != nil { return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("UTCTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tz = time.FixedZone("", -1*(tzHour*3600+tzMin*60))
|
tz = time.FixedZone("", -1*(tzHour*3600+tzMin*60))
|
||||||
bytes = bytes[5:]
|
bytes = bytes[5:]
|
||||||
|
@ -122,16 +140,24 @@ func parseGeneralizedTime (bytes []byte) (time.Time, error) {
|
||||||
return time.Time{}, errors.New("GeneralizedTime is too short")
|
return time.Time{}, errors.New("GeneralizedTime is too short")
|
||||||
}
|
}
|
||||||
year, err = bytesToInt(bytes[0:4])
|
year, err = bytesToInt(bytes[0:4])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
month, err = bytesToInt(bytes[4:6])
|
month, err = bytesToInt(bytes[4:6])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
day, err = bytesToInt(bytes[6:8])
|
day, err = bytesToInt(bytes[6:8])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
hour, err = bytesToInt(bytes[8:10])
|
hour, err = bytesToInt(bytes[8:10])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
bytes = bytes[10:]
|
bytes = bytes[10:]
|
||||||
|
|
||||||
|
@ -174,10 +200,14 @@ func parseGeneralizedTime (bytes []byte) (time.Time, error) {
|
||||||
return time.Time{}, errors.New("GeneralizedTime positive timezone offset is too short")
|
return time.Time{}, errors.New("GeneralizedTime positive timezone offset is too short")
|
||||||
}
|
}
|
||||||
tzHour, err := bytesToInt(bytes[1:3])
|
tzHour, err := bytesToInt(bytes[1:3])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tzMin, err := bytesToInt(bytes[3:5])
|
tzMin, err := bytesToInt(bytes[3:5])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tz = time.FixedZone("", tzHour*3600+tzMin*60)
|
tz = time.FixedZone("", tzHour*3600+tzMin*60)
|
||||||
bytes = bytes[5:]
|
bytes = bytes[5:]
|
||||||
|
@ -187,10 +217,14 @@ func parseGeneralizedTime (bytes []byte) (time.Time, error) {
|
||||||
return time.Time{}, errors.New("GeneralizedTime negative timezone offset is too short")
|
return time.Time{}, errors.New("GeneralizedTime negative timezone offset is too short")
|
||||||
}
|
}
|
||||||
tzHour, err := bytesToInt(bytes[1:3])
|
tzHour, err := bytesToInt(bytes[1:3])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tzMin, err := bytesToInt(bytes[3:5])
|
tzMin, err := bytesToInt(bytes[3:5])
|
||||||
if err != nil { return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error()) }
|
if err != nil {
|
||||||
|
return time.Time{}, errors.New("GeneralizedTime contains invalid integer: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
tz = time.FixedZone("", -1*(tzHour*3600+tzMin*60))
|
tz = time.FixedZone("", -1*(tzHour*3600+tzMin*60))
|
||||||
bytes = bytes[5:]
|
bytes = bytes[5:]
|
||||||
|
|
|
@ -94,7 +94,6 @@ var generalizedTimeTests = []timeTest{
|
||||||
{"20150210152542.1-0835", false, time.Time{}},
|
{"20150210152542.1-0835", false, time.Time{}},
|
||||||
{"20150210152542.-0835", false, time.Time{}},
|
{"20150210152542.-0835", false, time.Time{}},
|
||||||
|
|
||||||
|
|
||||||
{"", false, time.Time{}},
|
{"", false, time.Time{}},
|
||||||
{"123", false, time.Time{}},
|
{"123", false, time.Time{}},
|
||||||
{"2015021015+1000Z", false, time.Time{}},
|
{"2015021015+1000Z", false, time.Time{}},
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"software.sslmate.com/src/certspotter/ct"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"software.sslmate.com/src/certspotter/ct"
|
||||||
)
|
)
|
||||||
|
|
||||||
func reverseHashes(hashes []ct.MerkleTreeNode) {
|
func reverseHashes(hashes []ct.MerkleTreeNode) {
|
||||||
|
|
|
@ -10,19 +10,19 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"io"
|
"io"
|
||||||
"bufio"
|
"os"
|
||||||
"strings"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/net/idna"
|
"golang.org/x/net/idna"
|
||||||
|
|
||||||
"software.sslmate.com/src/certspotter"
|
"software.sslmate.com/src/certspotter"
|
||||||
"software.sslmate.com/src/certspotter/ct"
|
|
||||||
"software.sslmate.com/src/certspotter/cmd"
|
"software.sslmate.com/src/certspotter/cmd"
|
||||||
|
"software.sslmate.com/src/certspotter/ct"
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultStateDir() string {
|
func defaultStateDir() string {
|
||||||
|
@ -55,6 +55,7 @@ type watchlistItem struct {
|
||||||
Domain []string
|
Domain []string
|
||||||
AcceptSuffix bool
|
AcceptSuffix bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var watchlist []watchlistItem
|
var watchlist []watchlistItem
|
||||||
|
|
||||||
func parseWatchlistItem(str string) (watchlistItem, error) {
|
func parseWatchlistItem(str string) (watchlistItem, error) {
|
||||||
|
|
|
@ -10,18 +10,18 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"bytes"
|
|
||||||
"os/user"
|
"os/user"
|
||||||
"encoding/json"
|
|
||||||
"sync"
|
|
||||||
"strings"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"software.sslmate.com/src/certspotter"
|
"software.sslmate.com/src/certspotter"
|
||||||
"software.sslmate.com/src/certspotter/ct"
|
"software.sslmate.com/src/certspotter/ct"
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"software.sslmate.com/src/certspotter"
|
"software.sslmate.com/src/certspotter"
|
||||||
"software.sslmate.com/src/certspotter/ct"
|
|
||||||
"software.sslmate.com/src/certspotter/cmd"
|
"software.sslmate.com/src/certspotter/cmd"
|
||||||
|
"software.sslmate.com/src/certspotter/ct"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DefaultStateDir() string {
|
func DefaultStateDir() string {
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"software.sslmate.com/src/certspotter/ct"
|
|
||||||
"github.com/mreiferson/go-httpclient"
|
"github.com/mreiferson/go-httpclient"
|
||||||
|
"software.sslmate.com/src/certspotter/ct"
|
||||||
)
|
)
|
||||||
|
|
||||||
// URI paths for CT Log endpoints
|
// URI paths for CT Log endpoints
|
||||||
|
|
16
helpers.go
16
helpers.go
|
@ -10,21 +10,21 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
|
"encoding/pem"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"crypto/sha256"
|
"time"
|
||||||
"encoding/hex"
|
|
||||||
"encoding/pem"
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"software.sslmate.com/src/certspotter/ct"
|
"software.sslmate.com/src/certspotter/ct"
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,10 +11,10 @@ package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"strings"
|
|
||||||
"net"
|
|
||||||
"unicode/utf8"
|
|
||||||
"golang.org/x/net/idna"
|
"golang.org/x/net/idna"
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
const UnparsableDNSLabelPlaceholder = "<unparsable>"
|
const UnparsableDNSLabelPlaceholder = "<unparsable>"
|
||||||
|
|
2
logs.go
2
logs.go
|
@ -10,9 +10,9 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"crypto"
|
"crypto"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"encoding/base64"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LogInfoFile struct {
|
type LogInfoFile struct {
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"errors"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bitStringEqual(a, b *asn1.BitString) bool {
|
func bitStringEqual(a, b *asn1.BitString) bool {
|
||||||
|
@ -25,6 +25,7 @@ var (
|
||||||
oidExtensionSCT = []int{1, 3, 6, 1, 4, 1, 11129, 2, 4, 2}
|
oidExtensionSCT = []int{1, 3, 6, 1, 4, 1, 11129, 2, 4, 2}
|
||||||
oidExtensionCTPoison = []int{1, 3, 6, 1, 4, 1, 11129, 2, 4, 3}
|
oidExtensionCTPoison = []int{1, 3, 6, 1, 4, 1, 11129, 2, 4, 3}
|
||||||
)
|
)
|
||||||
|
|
||||||
func ValidatePrecert(precertBytes []byte, tbsBytes []byte) error {
|
func ValidatePrecert(precertBytes []byte, tbsBytes []byte) error {
|
||||||
precert, err := ParseCertificate(precertBytes)
|
precert, err := ParseCertificate(precertBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -14,13 +14,13 @@ package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "container/list"
|
// "container/list"
|
||||||
|
"crypto"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
"crypto"
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
"software.sslmate.com/src/certspotter/ct"
|
"software.sslmate.com/src/certspotter/ct"
|
||||||
"software.sslmate.com/src/certspotter/ct/client"
|
"software.sslmate.com/src/certspotter/ct/client"
|
||||||
|
@ -233,7 +233,7 @@ func (s *Scanner) CheckConsistency(first *ct.SignedTreeHead, second *ct.SignedTr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scanner) Scan(startIndex int64, endIndex int64, processCert ProcessCallback, treeBuilder *MerkleTreeBuilder) error {
|
func (s *Scanner) Scan(startIndex int64, endIndex int64, processCert ProcessCallback, treeBuilder *MerkleTreeBuilder) error {
|
||||||
s.Log("Starting scan...");
|
s.Log("Starting scan...")
|
||||||
|
|
||||||
s.certsProcessed = 0
|
s.certsProcessed = 0
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
37
x509.go
37
x509.go
|
@ -10,13 +10,13 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"time"
|
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -60,6 +60,7 @@ const (
|
||||||
sanIPAddress = 7
|
sanIPAddress = 7
|
||||||
sanRegisteredID = 8
|
sanRegisteredID = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
type SubjectAltName struct {
|
type SubjectAltName struct {
|
||||||
Type int
|
Type int
|
||||||
Value []byte
|
Value []byte
|
||||||
|
@ -95,7 +96,6 @@ type Certificate struct {
|
||||||
SignatureValue asn1.RawValue
|
SignatureValue asn1.RawValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (rdns RDNSequence) ParseCNs() ([]string, error) {
|
func (rdns RDNSequence) ParseCNs() ([]string, error) {
|
||||||
var cns []string
|
var cns []string
|
||||||
|
|
||||||
|
@ -118,15 +118,24 @@ func (rdns RDNSequence) ParseCNs () ([]string, error) {
|
||||||
|
|
||||||
func rdnLabel(oid asn1.ObjectIdentifier) string {
|
func rdnLabel(oid asn1.ObjectIdentifier) string {
|
||||||
switch {
|
switch {
|
||||||
case oid.Equal(oidCountry): return "C"
|
case oid.Equal(oidCountry):
|
||||||
case oid.Equal(oidOrganization): return "O"
|
return "C"
|
||||||
case oid.Equal(oidOrganizationalUnit): return "OU"
|
case oid.Equal(oidOrganization):
|
||||||
case oid.Equal(oidCommonName): return "CN"
|
return "O"
|
||||||
case oid.Equal(oidSerialNumber): return "serialNumber"
|
case oid.Equal(oidOrganizationalUnit):
|
||||||
case oid.Equal(oidLocality): return "L"
|
return "OU"
|
||||||
case oid.Equal(oidProvince): return "ST"
|
case oid.Equal(oidCommonName):
|
||||||
case oid.Equal(oidStreetAddress): return "street"
|
return "CN"
|
||||||
case oid.Equal(oidPostalCode): return "postalCode"
|
case oid.Equal(oidSerialNumber):
|
||||||
|
return "serialNumber"
|
||||||
|
case oid.Equal(oidLocality):
|
||||||
|
return "L"
|
||||||
|
case oid.Equal(oidProvince):
|
||||||
|
return "ST"
|
||||||
|
case oid.Equal(oidStreetAddress):
|
||||||
|
return "street"
|
||||||
|
case oid.Equal(oidPostalCode):
|
||||||
|
return "postalCode"
|
||||||
}
|
}
|
||||||
return oid.String()
|
return oid.String()
|
||||||
}
|
}
|
||||||
|
@ -319,7 +328,6 @@ func (tbs *TBSCertificate) GetExtension (id asn1.ObjectIdentifier) []Extension {
|
||||||
return exts
|
return exts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func ParseCertificate(certBytes []byte) (*Certificate, error) {
|
func ParseCertificate(certBytes []byte) (*Certificate, error) {
|
||||||
var cert Certificate
|
var cert Certificate
|
||||||
if rest, err := asn1.Unmarshal(certBytes, &cert); err != nil {
|
if rest, err := asn1.Unmarshal(certBytes, &cert); err != nil {
|
||||||
|
@ -366,4 +374,3 @@ func parseSANExtension (sans []SubjectAltName, value []byte) ([]SubjectAltName,
|
||||||
|
|
||||||
return sans, nil
|
return sans, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue