iOS Jenkins打包报错401 Authentication credentials are missing or invalid.解决办法

简介: iOS Jenkins打包报错401 Authentication credentials are missing or invalid.解决办法

报错原文:

gen_jwt_s.rb:3:in `initialize': invalid curve name (OpenSSL::PKey::ECError)
    from gen_jwt_s.rb:3:in `new'
    from gen_jwt_s.rb:3:in `<main>'
JWT_TOKEN=
创建cer证书
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: POST
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1324  100   350  100   974    489   1360 --:--:-- --:--:-- --:--:--  1851
{ "errors": [ { "status": "401", "code": "NOT_AUTHORIZED", "title": "Authentication credentials are missing or invalid.", "detail": "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests [https://developer.apple.com/go/?id=api-generating-tokens](https://developer.apple.com/go/?id=api-generating-tokens)" } ] }</pre>


报错分析:


可以看出是请求https://developer.apple.com/go/?id=api-generating-tokens这个生成token的接口报错了,看报错信息可以看到是生成token的脚本gen_jwt_s.rb里面出现的错误,在脚本的第三行出现的错误

生成token的脚本代码:

require 'jwt'
ecdsa_key = OpenSSL::PKey::EC.new File.read "AuthKey.p8"
ecdsa_key.private? #=>true
payload = {
    "iss": "xxx",
    "exp": Time.now.to_i + 1200,
    "aud": "appstoreconnect-v1"
  }
header = {
    "alg": "ES256",
    "kid": "xxx",
    "typ": "JWT"
  }
token = JWT.encode payload, ecdsa_key, 'ES256',header
#puts "生成Token成功有效时间是20分钟:"
puts token
aFile = File.new("token.txt", "r+")
if aFile
   aFile.syswrite(token)
else
   puts "Unable to open file!"
end


其中第三行代码是:

ecdsa_key = OpenSSL::PKey::EC.new File.read "AuthKey.p8"


可以推测出是读取p8文件时出现错误,检查了一下p8文件,发现我们这边下载p8文件的链接失效了,所以导致了无法读取p8文件。


解决办法:

1.重新上传p8文件到服务器

2.也可能是存放p8文件的服务出了问题,修复即可

目录
相关文章
|
5月前
|
jenkins Unix 持续交付
个人记录jenkins编译ios过程 xcode是9.4.1
个人记录jenkins编译ios过程 xcode是9.4.1
69 2
|
5月前
|
移动开发 前端开发 数据安全/隐私保护
iOS发布证书.p12文件无密码解决办法及导出带密码的新.p12文件方法
iOS发布证书.p12文件无密码解决办法及导出带密码的新.p12文件方法
159 0
|
2月前
|
iOS开发 MacOS Perl
解决Xcode运行IOS报错:redefinition of module ‘Firebase‘和could not build module ‘CoreFoundation‘
解决Xcode运行IOS报错:redefinition of module ‘Firebase‘和could not build module ‘CoreFoundation‘
89 4
|
2月前
|
Swift iOS开发
iOS Swift使用Alamofire请求本地服务器报错-1002
iOS Swift使用Alamofire请求本地服务器报错-1002
67 1
|
5月前
|
资源调度 jenkins 持续交付
jenkins 自动安装nodejs16.16.0版本报错处理
jenkins 自动安装nodejs16.16.0版本报错处理
683 0
|
24天前
|
iOS开发
url中带中文,ios报错问题
url中带中文,ios报错问题
|
2月前
|
iOS开发
IOS编译报错‘ZipArchive.h‘ file not found|Use of undeclared identifier ‘SSZipArchive‘
IOS编译报错‘ZipArchive.h‘ file not found|Use of undeclared identifier ‘SSZipArchive‘
37 1
|
2月前
|
iOS开发
解决Flutter运行IOS报错:Podfile is out of date
解决Flutter运行IOS报错:Podfile is out of date
45 1
|
2月前
|
存储 iOS开发 Perl
ios-解决报错-CocoaPods could not find compatible versions for pod “xxx“
ios-解决报错-CocoaPods could not find compatible versions for pod “xxx“
41 2
|
2月前
|
开发工具 iOS开发 容器
【Azure Blob】关闭Blob 匿名访问,iOS Objective-C SDK连接Storage Account报错
【Azure Blob】关闭Blob 匿名访问,iOS Objective-C SDK连接Storage Account报错
下一篇
无影云桌面