Code Monkey home page Code Monkey logo

Comments (5)

ezfe avatar ezfe commented on May 18, 2024 2

Just wanted to drop in and say that this issue occurred for me due to the lack of newlines, as I was trying to pass it in through an environment variable. When I added them back in, this issue went away.

from jwt.

ios-apps avatar ios-apps commented on May 18, 2024 1

I used .replacingOccurrences(of: "\\n", with: "\n") after private key reading from .env

from jwt.

gwynne avatar gwynne commented on May 18, 2024

This appears to be due to passing an X.509 certificate (a PEM blob starting with ------BEGIN CERTIFICATE------) to the public key initializer for RS256, which invokes PEM_read_bio_PUBKEY() - the PUBKEY variant expects a PKCS#8 public key (PEM blob starting with ------BEGIN PUBLIC KEY------, wrapping a SubjectPublicKeyInfo tagged as rsaEncryption and in turn containing an RSAPublicKey). While an X.509v3 certificate does indeed contain a public key, it unfortunately can not be directly parsed as if it were one.

JWTKit should provide a .public(x509:) convenience utility, since extracting a certificate's public key in PKCS#8 PEM form is either a ridiculous ring-around-the-rosy using NIOSSL, or else just painful using BoringSSL directly. However, this is not a bug as such.

from jwt.

abesmon avatar abesmon commented on May 18, 2024

Just message for future developers: jWTKit now providing x509 initialization thru .certificate(pem: cert)

from jwt.

rafaelclaycon avatar rafaelclaycon commented on May 18, 2024

Heads up to devs sending push notifications through their servers and omitting the Apple ECP8 Private Key from their code because they made the project public and don't want the key revealed: JWT will scream at you if it doesn't see a proper key passed

func configurePush() throws {
        let appleECP8PrivateKey =
        """
        -----BEGIN PRIVATE KEY-----
           <--- HERE!
        -----END PRIVATE KEY-----
        """
        
        apns.configuration = try .init(
            authenticationMethod: .jwt(
                key: .private(pem: Data(appleECP8PrivateKey.utf8)),
                keyIdentifier: "",
                teamIdentifier: ""
            ),
            topic: "com.rafaelschmitt.MyApp",
            environment: .production
        )
    }

Just comment this code out while you test.

from jwt.

Related Issues (20)

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.