mirror of
https://github.com/golang/go
synced 2024-11-18 08:44:43 -07:00
crypto/x509: skip SHA2 system verify test if not supported.
Windows XP SP2 and Windows 2003 do not support SHA2. Change-Id: Ica5faed040e9ced8b79fe78d512586e0e8788b3f Reviewed-on: https://go-review.googlesource.com/8167 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
9e6f7aac28
commit
cf7461caed
15
src/crypto/x509/sha2_windows_test.go
Normal file
15
src/crypto/x509/sha2_windows_test.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package x509
|
||||||
|
|
||||||
|
import "internal/syscall/windows"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if major, _ := windows.GetVersion(); major < 6 {
|
||||||
|
// Windows XP SP2 and Windows 2003 do not support SHA2.
|
||||||
|
// http://blogs.technet.com/b/pki/archive/2010/09/30/sha2-and-windows.aspx
|
||||||
|
supportSHA2 = false
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var supportSHA2 = true
|
||||||
|
|
||||||
type verifyTest struct {
|
type verifyTest struct {
|
||||||
leaf string
|
leaf string
|
||||||
intermediates []string
|
intermediates []string
|
||||||
@ -23,6 +25,7 @@ type verifyTest struct {
|
|||||||
systemSkip bool
|
systemSkip bool
|
||||||
keyUsages []ExtKeyUsage
|
keyUsages []ExtKeyUsage
|
||||||
testSystemRootsError bool
|
testSystemRootsError bool
|
||||||
|
sha2 bool
|
||||||
|
|
||||||
errorCallback func(*testing.T, int, error) bool
|
errorCallback func(*testing.T, int, error) bool
|
||||||
expectedChains [][]string
|
expectedChains [][]string
|
||||||
@ -218,6 +221,7 @@ var verifyTests = []verifyTest{
|
|||||||
currentTime: 1397502195,
|
currentTime: 1397502195,
|
||||||
dnsName: "api.moip.com.br",
|
dnsName: "api.moip.com.br",
|
||||||
|
|
||||||
|
sha2: true,
|
||||||
expectedChains: [][]string{
|
expectedChains: [][]string{
|
||||||
{
|
{
|
||||||
"api.moip.com.br",
|
"api.moip.com.br",
|
||||||
@ -297,6 +301,9 @@ func testVerify(t *testing.T, useSystemRoots bool) {
|
|||||||
if runtime.GOOS == "windows" && test.testSystemRootsError {
|
if runtime.GOOS == "windows" && test.testSystemRootsError {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if useSystemRoots && !supportSHA2 && test.sha2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
opts := VerifyOptions{
|
opts := VerifyOptions{
|
||||||
Intermediates: NewCertPool(),
|
Intermediates: NewCertPool(),
|
||||||
|
@ -97,6 +97,7 @@ const (
|
|||||||
//sys GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizeOfPointer *uint32) (errcode error) = iphlpapi.GetAdaptersAddresses
|
//sys GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizeOfPointer *uint32) (errcode error) = iphlpapi.GetAdaptersAddresses
|
||||||
|
|
||||||
//sys GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) = GetComputerNameExW
|
//sys GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) = GetComputerNameExW
|
||||||
|
//sys getVersion() (v uint32) = GetVersion
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ComputerNameNetBIOS = 0
|
ComputerNameNetBIOS = 0
|
||||||
@ -109,3 +110,8 @@ const (
|
|||||||
ComputerNamePhysicalDnsFullyQualified = 7
|
ComputerNamePhysicalDnsFullyQualified = 7
|
||||||
ComputerNameMax = 8
|
ComputerNameMax = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetVersion() (major, minor byte) {
|
||||||
|
low := uint16(getVersion())
|
||||||
|
return byte(low), byte(low >> 8)
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ var (
|
|||||||
|
|
||||||
procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
|
procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
|
||||||
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
|
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
|
||||||
|
procGetVersion = modkernel32.NewProc("GetVersion")
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizeOfPointer *uint32) (errcode error) {
|
func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizeOfPointer *uint32) (errcode error) {
|
||||||
@ -34,3 +35,9 @@ func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVersion() (v uint32) {
|
||||||
|
r0, _, _ := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
|
||||||
|
v = uint32(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user