Merge pull request #35 from github/bump-certstore

Fix panic on Windows
This commit is contained in:
Ben Toews 2018-11-08 09:39:43 -07:00 коммит произвёл GitHub
Родитель 8143ca9c10 df1dc177f7
Коммит a35b79e76b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 52 добавлений и 10 удалений

43
Gopkg.lock сгенерированный
Просмотреть файл

@ -2,82 +2,113 @@
[[projects]] [[projects]]
digest = "1:8722889ad027febfced94665914d1e7be8f1b703d31f2ef9461c59e4d40fe974"
name = "github.com/certifi/gocertifi" name = "github.com/certifi/gocertifi"
packages = ["."] packages = ["."]
pruneopts = ""
revision = "deb3ae2ef2610fde3330947281941c562861188b" revision = "deb3ae2ef2610fde3330947281941c562861188b"
version = "2018.01.18" version = "2018.01.18"
[[projects]] [[projects]]
digest = "1:0deddd908b6b4b768cfc272c16ee61e7088a60f7fe2f06c547bd3d8e1f8b8e77"
name = "github.com/davecgh/go-spew" name = "github.com/davecgh/go-spew"
packages = ["spew"] packages = ["spew"]
pruneopts = ""
revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
version = "v1.1.1" version = "v1.1.1"
[[projects]] [[projects]]
digest = "1:023fbbe144662cdcd931f9c47e29e5a0f89d01d340600c270aaaf887fe667edc"
name = "github.com/mastahyeti/certstore" name = "github.com/mastahyeti/certstore"
packages = ["."] packages = ["."]
revision = "6f2394a25c204d281922fe1407d4385a7b979963" pruneopts = ""
version = "0.0.3" revision = "c84a6bb0b6baafd35a9316317b4621c9d04c6813"
version = "0.0.4"
[[projects]] [[projects]]
digest = "1:26ab843f72f1e7b54b7ad984510a956926e623f880a26faca9375d2199d928d2"
name = "github.com/mastahyeti/cms" name = "github.com/mastahyeti/cms"
packages = [ packages = [
".", ".",
"oid", "oid",
"protocol", "protocol",
"timestamp" "timestamp",
] ]
pruneopts = ""
revision = "a229af0c48a09fb2fd15983d09eb47052521ce03" revision = "a229af0c48a09fb2fd15983d09eb47052521ce03"
version = "0.0.2" version = "0.0.2"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:915b4b548d2fc9dbead609376aabf7a95d0cb8764501d2a451495f7d394635b6"
name = "github.com/mastahyeti/fakeca" name = "github.com/mastahyeti/fakeca"
packages = ["."] packages = ["."]
pruneopts = ""
revision = "5f91b32d1226951f9631342eee20f5142387a216" revision = "5f91b32d1226951f9631342eee20f5142387a216"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:67235b35254a10a1763d608067d34cafaf88457c4054755a8b26a68b6a934ed3"
name = "github.com/pborman/getopt" name = "github.com/pborman/getopt"
packages = ["v2"] packages = ["v2"]
pruneopts = ""
revision = "2b5b3bfb099b7da3e2f433966f8ab1d5803e0876" revision = "2b5b3bfb099b7da3e2f433966f8ab1d5803e0876"
[[projects]] [[projects]]
digest = "1:7365acd48986e205ccb8652cc746f09c8b7876030d53710ea6ef7d0bd0dcd7ca"
name = "github.com/pkg/errors" name = "github.com/pkg/errors"
packages = ["."] packages = ["."]
pruneopts = ""
revision = "645ef00459ed84a119197bfb8d8205042c6df63d" revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
version = "v0.8.0" version = "v0.8.0"
[[projects]] [[projects]]
digest = "1:256484dbbcd271f9ecebc6795b2df8cad4c458dd0f5fd82a8c2fa0c29f233411"
name = "github.com/pmezard/go-difflib" name = "github.com/pmezard/go-difflib"
packages = ["difflib"] packages = ["difflib"]
pruneopts = ""
revision = "792786c7400a136282c1664665ae0a8db921c6c2" revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0" version = "v1.0.0"
[[projects]] [[projects]]
digest = "1:c587772fb8ad29ad4db67575dad25ba17a51f072ff18a22b4f0257a4d9c24f75"
name = "github.com/stretchr/testify" name = "github.com/stretchr/testify"
packages = [ packages = [
"assert", "assert",
"require" "require",
] ]
pruneopts = ""
revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686"
version = "v1.2.2" version = "v1.2.2"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:b2d8b39397ca07929a3de3a3fd2b6ca4c8d48e9cadaa7cf2b083e27fd9e78107"
name = "golang.org/x/crypto" name = "golang.org/x/crypto"
packages = [ packages = [
"cast5", "cast5",
"openpgp/elgamal", "openpgp/elgamal",
"openpgp/errors", "openpgp/errors",
"openpgp/packet", "openpgp/packet",
"openpgp/s2k" "openpgp/s2k",
] ]
pruneopts = ""
revision = "0709b304e793a5edb4a2c0145f281ecdc20838a4" revision = "0709b304e793a5edb4a2c0145f281ecdc20838a4"
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "beee101522fbba0ef4524626104699e2a2252d63076c4aa575c1b602a93adda6" input-imports = [
"github.com/certifi/gocertifi",
"github.com/mastahyeti/certstore",
"github.com/mastahyeti/cms",
"github.com/mastahyeti/cms/protocol",
"github.com/mastahyeti/fakeca",
"github.com/pborman/getopt/v2",
"github.com/pkg/errors",
"github.com/stretchr/testify/require",
"golang.org/x/crypto/openpgp/packet",
"golang.org/x/crypto/openpgp/s2k",
]
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

Просмотреть файл

@ -27,7 +27,7 @@
[[constraint]] [[constraint]]
name = "github.com/mastahyeti/certstore" name = "github.com/mastahyeti/certstore"
version = "0.0.3" version = "0.0.4"
[[constraint]] [[constraint]]
name = "github.com/mastahyeti/cms" name = "github.com/mastahyeti/cms"

17
vendor/github.com/mastahyeti/certstore/certstore_windows.go сгенерированный поставляемый
Просмотреть файл

@ -134,7 +134,7 @@ func (s *winStore) Identities() ([]Identity, error) {
idents = append(idents, newWinIdentity(chain)) idents = append(idents, newWinIdentity(chain))
} }
if err = lastError("failed to iterate certs in store"); err != nil && errors.Cause(err) != errCode(CRYPT_E_NOT_FOUND) { if err = checkError("failed to iterate certs in store"); err != nil && errors.Cause(err) != errCode(CRYPT_E_NOT_FOUND) {
goto fail goto fail
} }
@ -184,7 +184,7 @@ func (s *winStore) Import(data []byte, password string) error {
for { for {
// iterate through certs in temporary store // iterate through certs in temporary store
if ctx = C.CertFindCertificateInStore(store, encoding, 0, C.CERT_FIND_ANY, nil, ctx); ctx == nil { if ctx = C.CertFindCertificateInStore(store, encoding, 0, C.CERT_FIND_ANY, nil, ctx); ctx == nil {
if err := lastError("failed to iterate certs in store"); err != nil && errors.Cause(err) != errCode(CRYPT_E_NOT_FOUND) { if err := checkError("failed to iterate certs in store"); err != nil && errors.Cause(err) != errCode(CRYPT_E_NOT_FOUND) {
return err return err
} }
@ -612,8 +612,19 @@ func exportCertCtx(ctx C.PCCERT_CONTEXT) (*x509.Certificate, error) {
type errCode uint64 type errCode uint64
// lastError gets the last error from the current thread. // lastError gets the last error from the current thread. If there isn't one, it
// returns a new error.
func lastError(msg string) error { func lastError(msg string) error {
if err := checkError(msg); err != nil {
return err
}
return errors.New(msg)
}
// checkError tries to get the last error from the current thread. If there
// isn't one, it returns nil.
func checkError(msg string) error {
if code := errCode(C.GetLastError()); code != 0 { if code := errCode(C.GetLastError()); code != 0 {
return errors.Wrap(code, msg) return errors.Wrap(code, msg)
} }