How to authenticate the GKLocalPlayer on my 'third party server'?

后端 未结 10 444
鱼传尺愫
鱼传尺愫 2020-11-30 02:53

iOS7 introduced new GKLocalPlayer method generateIdentityVerificationSignatureWithCompletionHandler().

Does anyone know how to use it for good? I assum

10条回答
  •  甜味超标
    2020-11-30 03:22

    Here is my implementation in Elixir.

    def verify_login(player_id, public_key_url, timestamp, salt64, signature64, bundle_id) do
      salt = Base.decode64!(salt64)
      pay_load = <>
      pkey_cert = get_public_key_certificate(public_key_url)
      cert = :public_key.pkix_decode_cert(pkey_cert, :otp)
      case cert do
        {:OTPCertificate,
         {:OTPTBSCertificate, _, _, _, _, _, _,
          {:OTPSubjectPublicKeyInfo, _, key}, _, _, _}, _, _} ->
          signature = Base.decode64!(signature64)
          case :public_key.verify(pay_load, :sha256, signature, key) do
            true ->
              :ok
            false ->
              {:error, "apple login verify failed"}
          end
      end
    end
    
    def get_public_key_certificate(url) do
      case HTTPoison.get(url) do
        {:ok, %HTTPoison.Response{body: body}} ->
          body
      end
    end
    

提交回复
热议问题