Wednesday, October 28, 2026
HomeiOS Developmentios - Goal C: JWT generate token with algorithm ES256 utilizing

ios – Goal C: JWT generate token with algorithm ES256 utilizing

[ad_1]

I’m utilizing this Github library(https://cocoapods.org/pods/JWT) to create tokens utilizing JWT ES256.

I’m able to create a token utilizing the ruby operate and getting the token I wish to generate the identical token utilizing Goal C code

Right here is the ruby code

require "base64"
require "jwt"

ISSUER_ID = "69a6de83-fcea-47e3-e053-xxxxxxxxx"
KEY_ID = "JUV7......"

PATH = "/Customers/person/Paperwork/AuthKey/AuthKey_JUVxxxxx.p8"

private_key = OpenSSL::PKey.learn(File.learn(PATH))

token = JWT.encode(
   {    iss: ISSUER_ID,
        exp: Time.now.to_i + 20 * 60,
        aud: "appstoreconnect-v1"
   },
    private_key,
    "ES256",
    header_fields={
    child: KEY_ID }
    )

   places token

I attempted utilizing Goal-C code point out in library however no success

NSString *privateKeyString = @"<ANSI X9.63 formatted key>";
NSString *publicKeyString = @"<ANSI X9.63 formatted key>";

// Notice: We should always cross sort of key. Default sort is RSA.
NSDictionary *parameters = @{JWTCryptoKey.parametersKeyBuilder : 
JWTCryptoKeyBuilder.new.keyTypeEC};

id <JWTCryptoKeyProtocol> privateKey = [[JWTCryptoKeyPrivate alloc] 
initWithPemEncoded:privateKeyString parameters:parameters error:nil];
id <JWTCryptoKeyProtocol> publicKey = [[JWTCryptoKeyPublic alloc] 
initWithPemEncoded:publicKeyString parameters:parameters error:nil];

id <JWTAlgorithmDataHolderProtocol> holder = [JWTAlgorithmRSFamilyDataHolder 
new].signKey(privateKey).verifyKey(publicKey).algorithmName(JWTAlgorithmNameES256);

Please assist me with this.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments