Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to verify certificate" using a local replica #594

Open
LiveDuo opened this issue Sep 10, 2022 · 9 comments
Open

"Failed to verify certificate" using a local replica #594

LiveDuo opened this issue Sep 10, 2022 · 9 comments

Comments

@LiveDuo
Copy link

LiveDuo commented Sep 10, 2022

After updating to the later version v0.5.4.1 I consistently get an error saying "Failed to verify certificate" when using a local replica.

Screenshot 2022-09-10 at 4 52 59 PM

Repository: https://github.com/LiveDuo/plug-html-example

Wondering if someone has a working example of Plug extension working with a local replica after v0.5.3?

@LiveDuo
Copy link
Author

LiveDuo commented Sep 19, 2022

After quite some research it seems that there is no solution and this is a bug.

Pinging again as if this is true it's a big blocker for anyone that a local setup with Plug.

Happy to help in any way and get pass this issue.

Thread on Dfinity Forum:
https://forum.dfinity.org/t/anyone-updated-their-plug-wallet-to-version-v0-5-3-or-later/15359/7

@honopu
Copy link

honopu commented Sep 25, 2022

Same issue. The plug team has worked on it?

@LiveDuo
Copy link
Author

LiveDuo commented Sep 26, 2022

Same issue. The plug team has worked on it?

I'm not aware yet. When plug arrived it didn't support local development so many used mainnet. As time goes on and more switch to local, this issue will become more apparent. I'm sure the plug team will pick it up soon.

@riveign
Copy link
Collaborator

riveign commented Sep 27, 2022

@LiveDuo Hi we have worked on this issue during this release and it should be part of version 0.6

@LiveDuo
Copy link
Author

LiveDuo commented Sep 30, 2022

@LiveDuo Hi we have worked on this issue during this release and it should be part of version 0.6

Great to hear. Looking forward for the release.

@LiveDuo LiveDuo closed this as completed Oct 20, 2022
@LiveDuo LiveDuo reopened this Jul 14, 2023
@LiveDuo
Copy link
Author

LiveDuo commented Jul 14, 2023

The issue applies again

@zzqVip
Copy link

zzqVip commented May 14, 2024

This problem is still happening

@inviti8
Copy link

inviti8 commented Jan 15, 2025

I am also running into this bug. I have incorporated Authorization and canister calls using II, I tried adding Plug, and found that Authorization works, but when trying to make canister calls locally I get: "Error: Invalid certificate: Signature verification failed". I want to use Plug and II for my App, but this is a bit of a show stopper.

@inviti8
Copy link

inviti8 commented Jan 15, 2025

I'll add my code in case someone has a suggestion on whether or not I may be missing something when it comes to Plug. I have the wallet extension in Developer mode, with the local network added.

I get a failure with the error when making a canister call on the local network:
Error: Invalid certificate: Signature verification failed

An example of a motoko canister method that works with II, but not with Plug, looks like this:

public shared func release(user: Principal) : async Types.Released {
    if (Principal.equal(user, anonymous)){return false;};

    custodians := List.push(user, custodians);
    
    released := true;

    return released;
  };

The Method I use to Create my Plug Auth looks like this:

export class IC_PlugAuth {
  constructor(authButton, iface, whitelist, canisterId) {
    this.is = 'INTERNET_COMPUTER_PLUG_AUTH';
    this.AUTH_BUTTON = authButton;
    this.CANISTER_WHITE_LIST = whitelist;
    this.CANISTER_ID = canisterId;
    this.INTERFACE = iface;
    this.AGENT = undefined;
    this.ACTOR = undefined;
    this.PRINCIPAL = undefined;
  }
  async authenticate(){
    if(this.CANISTER_WHITE_LIST.length == 0 || this.CANISTER_ID == undefined || this.INTERFACE == undefined)
      return;
    const whitelist = this.CANISTER_WHITE_LIST;
    const onConnectionUpdate = this.onConnectionUpdate;

    this.AUTH_BUTTON.box.userData.loggedIn = await window.ic?.plug?.requestConnect({
      whitelist,
      onConnectionUpdate,
    });

    this.PRINCIPAL = await window.ic.plug.agent.getPrincipal();

  }
  async createActor(){

    if (window.ic.plug?.agent) {
      this.ACTOR = await window.ic.plug.createActor({
        canisterId: this.CANISTER_ID,
        interfaceFactory: this.INTERFACE,
      });
    };

    return this.ACTOR
  }
  async logout(){
    await window.ic.plug.disconnect();
  }
  async onConnectionUpdate(){
    await this.createActor();
  }

}

And make calls on the actor as follows:

this.released = await this.ACTOR.release(this.ACTIVE_AUTH.PRINCIPAL);

 
For comparison, my working II Auth object looks like this:

export class IC_IIAuth {
  constructor(authButton, canisterId, AuthClient, HttpAgent, createActor, idProvider) {
    this.is = 'INTERNET_COMPUTER_II_AUTH';
    this.AUTH_BUTTON = authButton;
    this.CANISTER_ID = canisterId;
    this.AUTH_CLIENT = AuthClient;
    this.HTTP_AGENT = HttpAgent;
    this.CREATE_ACTOR = createActor;
    this.ID_PROVIDER = idProvider;
    this.CLIENT = undefined;
    this.AGENT = undefined;
    this.ACTOR = undefined;
    this.PRINCIPAL = undefined;
  }
  async authenticate(){

    try{
      this.CLIENT = await this.AUTH_CLIENT.create();
    }catch(err){
      console.log(err);
    }
        
    try{
      await new Promise((resolve) => {
        this.CLIENT.login({
            identityProvider: this.ID_PROVIDER,
            onSuccess: resolve,
        });
      });
    }catch(err){
      console.log(err);
    }
    
    this.AUTH_BUTTON.box.userData.loggedIn = true;

    const identity = this.CLIENT.getIdentity();

    this.PRINCIPAL = identity.getPrincipal();

    this.AGENT = new this.HTTP_AGENT({identity});

  }
  async createActor(){
    const agent = this.AGENT;
    this.ACTOR = this.CREATE_ACTOR(this.CANISTER_ID, {
      agent,
    });

    return this.ACTOR
  }
  async logout(){
    await this.CLIENT.logout();
  }

}

I can't track down what the difference is, anyone out there who has some ideas, I'd be appreciative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants