Giter VIP home page Giter VIP logo

passkit's People

Contributors

alvinbaena avatar edouard-claude avatar myypo avatar nathan-tw avatar nimajalali avatar rwngallego avatar ryan-lang avatar sercand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

passkit's Issues

Failed on loading certificates "asn1: structure error: tags don't match"

Got an error

asn1: structure error: tags don't match (16 vs {class:0 tag:13 length:45 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} certificate @2

on calling passkit.LoadSigningInformationFromFiles(). Certificate files are valid, I use them for building passes in PHP.

What could that be?

Pass could not be opened

Screenshot 2023-11-03 at 12 23 51
c := passkit.NewBoardingPass(passkit.TransitTypeAir)
	field := passkit.Field{
		Key:   "name",
		Label: "Name",
		Value: passInfo.name,
	}

	c.AddHeaderField(field)
	c.AddPrimaryFields(field)
	c.AddSecondaryFields(field)
	c.AddAuxiliaryFields(field)
	c.AddBackFields(field)

	pass := passkit.Pass{
		FormatVersion:      1,
		TeamIdentifier:     "xxxx",
		PassTypeIdentifier: "xxxx",
		OrganizationName:   "xxxx",
		SerialNumber:       "1234",
		Description:        "Card",
		BoardingPass:       c,
		Barcodes: []passkit.Barcode{
			{
				Format:          passkit.BarcodeFormatQR,
				Message:         "xxx",
				MessageEncoding: "utf-8",
			},
		},
	}

template := passkit.NewInMemoryPassTemplate()

iconUrl, _ := url.ParseRequestURI("xxxx")
template.AddFileFromURL(passkit.BundleIcon, *iconUrl)
template.AddFileFromURL(passkit.BundleThumbnail, *iconUrl)

signer := passkit.NewMemoryBasedSigner()
	signInfo, err := passkit.LoadSigningInformationFromFiles(
		"apple.pass/Certificates.p12",
		"xxxx",
		"apple.pass/wwdr.cer",
	)
	if err != nil {
		panic(err)
	}

	z, err := signer.CreateSignedAndZippedPassArchive(&pass, template, signInfo)
	if err != nil {
		panic(err)
	}

	err = os.WriteFile("pass.pkpass", z, 0644)
	if err != nil {
		panic(err)
	}

The pass.pkpass file is created.

unzip pass.pkpass 
Archive:  pass.pkpass
  inflating: signature               
  inflating: icon.png                
  inflating: thumbnail.png           
  inflating: pass.json               
  inflating: manifest.json           

And all files are included.

x509: malformed certificate

With an exported WWDR certificate (https://www.apple.com/certificateauthority/AppleWWDRCAG4.cer):

        signInfo, err := passkit.LoadSigningInformationFromFiles(
		"apple.pass/Certificates.p12",
		"xxxxxxxx",
		"apple.pass/wwdr.pem",
	)
	if err != nil {
		panic(err)
	}
2023/11/01 23:56:09 http: panic serving 127.0.0.1:59909: x509: malformed certificate
goroutine 65 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1868 +0xb9
panic({0x1664420?, 0xc000486310?})
        /usr/local/go/src/runtime/panic.go:920 +0x270
main.SignAndStore({0x1, {0x17655d1, 0x4}, {0x1774ca0, 0x19}, {0x0, 0x0}, {0x176f8f4, 0x12}, {0x176f906, ...}, ...}, ...)
        /Users/theobouwman/dev/projects/momo/momo-wallet-pass-api/pass.go:68 +0x129
main.(*App).Handler(0x18617e0?, {0x18603f0?, 0xc0003d22a0}, 0xc000163100)
        /Users/theobouwman/dev/projects/momo/momo-wallet-pass-api/handler.go:40 +0x1e5
net/http.HandlerFunc.ServeHTTP(0xc000163000?, {0x18603f0?, 0xc0003d22a0?}, 0x2f8ea50?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0000ec000, {0x18603f0, 0xc0003d22a0}, 0xc000162f00)
        /Users/theobouwman/go/pkg/mod/github.com/gorilla/[email protected]/mux.go:210 +0x1c5
net/http.serverHandler.ServeHTTP({0xc0003fa930?}, {0x18603f0?, 0xc0003d22a0?}, 0x6?)
        /usr/local/go/src/net/http/server.go:2938 +0x8e
net/http.(*conn).serve(0xc0001c9320, {0x18617e0, 0xc0003fa3c0})
        /usr/local/go/src/net/http/server.go:2009 +0x5f4
created by net/http.(*Server).Serve in goroutine 45
        /usr/local/go/src/net/http/server.go:3086 +0x5cb

Failed to add pass error

Upon generating the .pkpass from the file template, the iOS Simulator throws the following error instead of loading the pass:

Failed to add pass: 'file:///Users/dev/Documents/projects/pass/pass.pkpass' Error Domain=PKPassKitErrorDomain Code=1 "No data supplied" UserInfo={NSLocalizedDescription=No data supplied}.

I've used the code from the README to generate the .pkpass:

package main

import (
	"archive/zip"
	"bytes"
	"fmt"
	"io/ioutil"
	"os"

	"github.com/alvinbaena/passkit"
	"github.com/google/uuid"
)

func main() {

	c := passkit.NewGenericPass()

	field := passkit.Field{
		Key:   "key",
		Label: "label",
		Value: "value",
	}

	serial := uuid.NewString()

	fmt.Printf("pass id: %s\n", serial)

	c.AddHeaderField(field)
	c.AddPrimaryFields(field)
	c.AddSecondaryFields(field)
	c.AddAuxiliaryFields(field)
	c.AddBackFields(field)

	pass := passkit.Pass{
		FormatVersion:      1,
		TeamIdentifier:     "==TEAM-ID==",
		PassTypeIdentifier: "==Pass-Identifier==",
		OrganizationName:   "orgName",
		SerialNumber:       serial,
		Description:        "test",
		Generic:            c,
		Barcodes: []passkit.Barcode{
			{
				Format:          passkit.BarcodeFormatQR,
				Message:         "1312312312312312312312312312",
				MessageEncoding: "utf-8",
			},
		},
	}

	template := passkit.NewFolderPassTemplate("passes/mypass.pass")

	signInfo, err := passkit.LoadSigningInformationFromFiles("certs/passmaker.p12", "test", "certs/wwdr.cer")

	signer := passkit.NewMemoryBasedSigner()

	if err != nil {
		panic(err)
	}

	fmt.Print("Pass signed\n")

	z, err := signer.CreateSignedAndZippedPassArchive(&pass, template, signInfo)

	if err != nil {
		fmt.Println("Error creating archive:", err)
		return
	}

	fmt.Print("Archive Created\n")

	err = os.WriteFile("pass.pkpass", z, 0644)

	if err != nil {
		panic(err)
	}

	fmt.Print("Finished creating pass\n")
}

No certificate errors are being thrown, so I think it's safe to say it's not related to certificates/signing.

I'm using the the Generic.pass from Apple as a template, and replaced the values of the JSON with the above fields. I also printed the contents of the pass.json after it was loaded into memory and all the fields were filled out as they were supposed to be, but I still get this error.

License

Thanks for the great package! Noticed there was no License attached to it.

Can one be added? MIT?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.