1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
# apkverifier
[](https://godoc.org/github.com/avast/apkverifier)
[](https://travis-ci.org/avast/apkverifier)
APK signature verification, should support all algorithms and both scheme v1 and v2,
including downgrade attack protection.
**Works with Go 1.8 or higher.**
Documentation on [GoDoc](https://godoc.org/github.com/avast/apkverifier)
go get github.com/avast/apkverifier
## Vendored stuff
Because Android can handle even broken x509 cerficates and ZIP files, apkverifier is using the ZipReader from apkparser
package and vendors `crypto/x509` in `internal/x509andr` and [github.com/fullsailor/pkcs7](https://github.com/fullsailor/pkcs7)
in the `fullsailor/pkcs7` folder.
The last two have some changes to handle some not-entirely-according-to-spec certificates.
## Example
```go
package main
import (
"fmt"
"github.com/avast/apkverifier"
"os"
)
func main() {
res, err := apkverifier.Verify(os.Args[1], nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Verification failed: %s\n", err.Error())
}
fmt.Printf("Verification scheme used: v%d\n", res.SigningSchemeId)
cert, _ := apkverifier.PickBestApkCert(res.SignerCerts)
if cert == nil {
fmt.Printf("No certificate found.\n")
} else {
fmt.Println(cert)
}
}
```
|