我正在尝试生成令牌以对我对iTunes Connect API的请求进行签名。那是我的Ruby文件:
require "jwt"
require 'openssl'
ISSUER_ID = "my issuer string"
KEY_ID = "my key id string"
key_file = File.read('my p8 file containing my private key') # Located at the same folder than my ruby file
private_key = OpenSSL::PKey::RSA.new(key_file)
payload = {
'iss': ISSUER_ID,
'exp': 1528408800,
'aud': 'appstoreconnect-v1'
}
header = {
'alg': 'ES256',
'kid': KEY_ID,
'typ': 'JWT'
}
jwt = JWT.encode(payload, private_key, algorithm='ES256', header)
puts jwt
如果运行此文件ruby jwt.rb
,则会得到以下输出:
/Library/Ruby/Gems/2.3.0/gems/jwt-2.1.0/lib/jwt/algos/ecdsa.rb:15:in sign':undefined method group'for#(NoMethodError) 来自/Library/Ruby/Gems/2.3.0/gems/jwt-2.1.0/lib/jwt/signature.rb:35:in sign' 来自/Library/Ruby/Gems/2.3.0/gems/jwt-2.1.0/lib/jwt/encode.rb:39:in encode_signature' 来自/Library/Ruby/Gems/2.3.0/gems/jwt-2.1.0/lib/jwt/encode.rb:47:位于encode_segments中 来自/Library/Ruby/Gems/2.3.0/gems/jwt-2.1.0/lib/jwt/encode.rb:20:in initialize' 来自/Library/Ruby/Gems/2.3.0/gems/jwt-2.1.0/lib/jwt.rb:21:in new' 来自/Library/Ruby/Gems/2.3.0/gems/jwt-2.1.0/lib/jwt.rb:21:in编码' 来自jwt.rb:22:in'
很难从控制台输出中看出失败的原因,但是如果我使用RS256作为算法并省略标题,则脚本会成功生成令牌。
答案 0 :(得分:1)
似乎是由于将RSA密钥与ECDSA加密算法结合使用引起的。要么使用RS256
代替ES256
,要么使用OpenSSL::PKey::EC
代替OpenSSL::PKey::RSA
(尽管如此,您可能需要一个新的私钥)。
答案 1 :(得分:0)
有import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.style.use('classic')
fig = plt.figure()
E = 200*10**9
I = 0.0001
beamLength = 5
loadPositions = np.array([1,5,2,4,2.5,3.5])
loadForces = np.array([-800000,300000,200000,-528584,255040,-256356])
beamSupport = 'cantilever'
n = 1000
nrOfEval = np.linspace(0, beamLength,n)
deflection = np.ones([len(nrOfEval),len(loadPositions)])
if beamSupport == 'both':
for i in range(len(nrOfEval)):
for j in range(len(loadPositions)):
if nrOfEval[i] < loadPositions[j]:
deflection[i,j] = loadForces[j]*(beamLength-loadPositions[j])*nrOfEval[i]/(6*E*I*beamLength)*(beamLength**2-nrOfEval[i]**2-(beamLength-loadPositions[j])**2)
if nrOfEval[i] >= loadPositions[j]:
deflection[i,j] = loadForces[j]*loadPositions[j]*(beamLength-nrOfEval[i])/(6*E*I*beamLength)*(beamLength**2-(beamLength-nrOfEval[i])**2-loadPositions[j]**2)
elif beamSupport == 'cantilever':
for i in range(len(nrOfEval)):
for j in range(len(loadPositions)):
if nrOfEval[i] < loadPositions[j]:
deflection[i,j] = loadForces[j]*nrOfEval[i]**2/(6*E*I)*(3*loadPositions[j]-nrOfEval[i])
if nrOfEval[i] >= loadPositions[j]:
deflection[i,j] = loadForces[j]*loadPositions[j]**2/(6*E*I)*(3*nrOfEval[i]-loadPositions[j])
else:
deflection = 'wrong support input'
deflection = np.sum(deflection,axis=1)
maxDeflectionIndex = np.abs(deflection).argmax()
print ("The maximum is at position::", maxDeflectionIndex)
maxDeflectionValue = deflection[maxDeflectionIndex]
print(maxDeflectionValue)
scaleForces = max(abs(loadForces))
fig, ax = plt.subplots()
ax.plot(nrOfEval,deflection)
plt.xlabel('Length[m]')
plt.ylabel('Deflection[mm]')
ax.axis('equal')
print('her')
ax.annotate('Maximum deflection', xy=(maxDeflectionIndex/n*beamLength, maxDeflectionValue), xytext=(maxDeflectionIndex/n*beamLength-0.7, 1),
arrowprops=dict(arrowstyle="->",
connectionstyle="angle3,angleA=0,angleB=-90"));
ax.annotate('F1', xy=(loadPositions[0], deflection[int(round(n/beamLength*loadPositions[0]))-1]), xytext=(loadPositions[0], loadForces[0]/scaleForces+deflection[int(round(n/beamLength*loadPositions[0]))-1]),
arrowprops=dict(facecolor='black', shrink=0))
ax.annotate('F2', xy=(loadPositions[1], deflection[int(round(n/beamLength*loadPositions[1]))-1]), xytext=(loadPositions[1], loadForces[1]/scaleForces+deflection[int(round(n/beamLength*loadPositions[1]))-1]),
arrowprops=dict(facecolor='black', shrink=0))
ax.annotate('F3', xy=(loadPositions[2], deflection[int(round(n/beamLength*loadPositions[2]))-1]), xytext=(loadPositions[2], loadForces[2]/scaleForces+deflection[int(round(n/beamLength*loadPositions[2]))-1]),
arrowprops=dict(facecolor='black', shrink=0))
ax.annotate('F4', xy=(loadPositions[3], deflection[int(round(n/beamLength*loadPositions[3]))-1]), xytext=(loadPositions[3], loadForces[3]/scaleForces+deflection[int(round(n/beamLength*loadPositions[3]))-1]),
arrowprops=dict(facecolor='black', shrink=0))
ax.annotate('F5', xy=(loadPositions[4], deflection[int(round(n/beamLength*loadPositions[4]))-1]), xytext=(loadPositions[4], loadForces[4]/scaleForces+deflection[int(round(n/beamLength*loadPositions[4]))-1]),
arrowprops=dict(facecolor='black', shrink=0))
ax.annotate('F6', xy=(loadPositions[5], deflection[int(round(n/beamLength*loadPositions[5]))-1]), xytext=(loadPositions[5], loadForces[5]/scaleForces+deflection[int(round(n/beamLength*loadPositions[5]))-1]),
arrowprops=dict(facecolor='black', shrink=0))
plt.show
个gem,它以现代Apple方式实现Apple推送通知:
...
sessionFactory.getCurrentSession().update(shop);
sessionFactory.getCurrentSession().commit();
...
+ Apnotic
+ HTTP2.0
。
可能您可以在其ProviderToken class中找到解决方案。