Skip to content

Commit b74f2ef

Browse files
crypto/x509: use the platform verifier on iOS
Use the same certificate verification APIs on iOS as on macOS (they share the same APIs, so we should be able to transparently use them on both.) Updates #46287 Fixes #38843 Change-Id: If70f99b0823dd5fa747c42ff4f20c3b625605327 Reviewed-on: https://go-review.googlesource.com/c/go/+/353403 Trust: Roland Shoemaker <roland@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org>
1 parent 09e8de7 commit b74f2ef

10 files changed

+5
-5115
lines changed

src/cmd/dist/test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,6 @@ func (t *tester) registerTests() {
499499
})
500500
}
501501

502-
if t.iOS() && !t.compileOnly {
503-
t.tests = append(t.tests, distTest{
504-
name: "x509omitbundledroots",
505-
heading: "crypto/x509 without bundled roots",
506-
fn: func(dt *distTest) error {
507-
t.addCmd(dt, "src", t.goTest(), t.timeout(300), "-tags=x509omitbundledroots", "-run=OmitBundledRoots", "crypto/x509")
508-
return nil
509-
},
510-
})
511-
}
512-
513502
// Test ios/amd64 for the iOS simulator.
514503
if goos == "darwin" && goarch == "amd64" && t.cgoEnabled {
515504
t.tests = append(t.tests, distTest{

src/crypto/x509/cert_pool.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ func SystemCertPool() (*CertPool, error) {
108108
return nil, errors.New("crypto/x509: system root pool is not available on Windows")
109109
} else if runtime.GOOS == "darwin" {
110110
return nil, errors.New("crypto/x509: system root pool is not available on macOS")
111+
} else if runtime.GOOS == "ios" {
112+
return nil, errors.New("crypto/x509: system root pool is not available on iOS")
111113
}
112114

113115
if sysRoots := systemRootsPool(); sysRoots != nil {

src/crypto/x509/root_darwin.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !ios
6-
75
package x509
86

97
import (

src/crypto/x509/root_ios.go

Lines changed: 0 additions & 4872 deletions
This file was deleted.

src/crypto/x509/root_ios_gen.go

Lines changed: 0 additions & 180 deletions
This file was deleted.

src/crypto/x509/root_omit.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/crypto/x509/root_omit_test.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/crypto/x509/verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ func (c *Certificate) Verify(opts VerifyOptions) (chains [][]*Certificate, err e
742742
}
743743

744744
// Use platform verifiers, where available
745-
if opts.Roots == nil && (runtime.GOOS == "windows" || runtime.GOOS == "darwin") {
745+
if opts.Roots == nil && (runtime.GOOS == "windows" || runtime.GOOS == "darwin" || runtime.GOOS == "ios") {
746746
return c.systemVerify(&opts)
747747
}
748748

src/crypto/x509/verify_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ func TestLongChain(t *testing.T) {
18361836
}
18371837

18381838
func TestSystemRootsError(t *testing.T) {
1839-
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
1839+
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
18401840
t.Skip("Windows and darwin do not use (or support) systemRoots")
18411841
}
18421842

src/crypto/x509/x509_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ func TestMultipleRDN(t *testing.T) {
19751975
}
19761976

19771977
func TestSystemCertPool(t *testing.T) {
1978-
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
1978+
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
19791979
t.Skip("not implemented on Windows (Issue 16736, 18609) or darwin (Issue 46287)")
19801980
}
19811981
a, err := SystemCertPool()

0 commit comments

Comments
 (0)