美文网首页
iOS Jenkins打包报错401 Authenticatio

iOS Jenkins打包报错401 Authenticatio

作者: anny_4243 | 来源:发表于2022-11-23 16:54 被阅读0次

报错原文:

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文件的服务出了问题,修复即可

相关文章

网友评论

      本文标题:iOS Jenkins打包报错401 Authenticatio

      本文链接:https://www.haomeiwen.com/subject/acedlrtx.html