Exemple #1
0
        private void OnClickRegistration(object sender, EventArgs e)
        {
            string Tag = "OnClickRegistration";

            if (!fido2Client.IsSupported)
            {
                log.Info(Tag, "FIDO2 is not supported.");
                return;
            }

            IFidoServer fidoServer = new FidoServerSimulator();

            if (fidoServer == null)
            {
                log.Error(Tag, GetString(Resource.String.connect_server_err));
                return;
            }
            ServerPublicKeyCredentialCreationOptionsRequest request = GetRegServerPublicKeyCredentialCreationOptionsRequest();

            if (request == null)
            {
                return;
            }
            // Obtain the challenge value and related policy from the FIDO server, and initiate a Fido2RegistrationRequest
            // request.
            ServerPublicKeyCredentialCreationOptionsResponse response = fidoServer.GetAttestationOptions(request);

            if (!ServerStatus.Ok.Equals(response.GetStatus()))
            {
                log.Error(Tag, GetString(Resource.String.reg_fail) + response.GetErrorMessage());
            }
            PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptions =
                ServerUtils.ConvertToPublicKeyCredentialCreationOptions(fido2Client, response);

            RegisterToFido2Client(publicKeyCredentialCreationOptions);
        }