dfinity / cancan

A scalable video sharing service.

Home Page:http://sdk.dfinity.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled Rejection (Error): Fail to verify certificate

stephenplusplus opened this issue · comments

Hello! I'm trying to run this app, but am met with an error after authenticating through https://identity.ic0.app/#authorize. After signing in, I am redirected to localhost:3000, when it tries to set me up with a username. It is during that call that this error is returned.

Unhandled Rejection (Error): Fail to verify certificate
pollForResponse
src/polling/index.ts:35
  32 | switch (status) {
  33 |     case RequestStatusResponseStatus.Replied: {
  34 |         return cert.lookup([...path, blobFromText('reply')]);
> 35 |     }
  36 | ^   case RequestStatusResponseStatus.Received:
  37 |     case RequestStatusResponseStatus.Unknown:
  38 |     case RequestStatusResponseStatus.Processing:

async caller
src/actor.ts:318

async getUserNameByPrincipal
src/utils/canister.ts:42
  39 | }
  40 | 
  41 | export async function getUserNameByPrincipal(principal: Principal) {
> 42 |   const icUserName = unwrap<string>(
  43 |     await CanCan.getUserNameByPrincipal(principal)
  44 |   )!;
  45 |   return icUserName;

Thanks for any help!

It looks like you are trying to use the “real” Internet Identity instance to log into a local canister. This is not supported yet; see https://forum.dfinity.org/t/dfinity-auth-client-403-response/3618/8?u=nomeata for more information

Before making the issue, I tried running the identity app locally and updated the code to point to localhost. I got the idea from the readme: https://github.com/dfinity/cancan#internet-identity-the-app-formerly-known-as-idp-locally, however the mentioned environment variable did not seem to have an effect. I had to go into node_modules and hard code the localhost address in one of the @dfinity/* modules. It seemed to work— I was directed to my localhost UI from cancan, but when it returned me to cancan, the same error happened at the same time as when I used the production identity provider. (Which is why I didn’t mention all this in my original post, sorry!)

Is the way from the readme to connect the cancan app with the local identity UI still correct?

@stephenplusplus thanks for checking out the project! The Fail to verify certificate error should be fixed by ensuring you call agent.fetchRootKey when you create the agent when on local development. This is an async function so be sure to await for it's completion before running calls against the canister. I opened a PR to fix this for the CanCan project here: #19.

Additionally, you will have to run the identity service locally for local development, at least for now. I'm in the process of figuring that part out for CanCan and writing up better documentation for it.

Thanks for your patience, I'll hope to have a better example of using the internet identity locally in this project by this week!

This should be fixed now with #19. This sets up the identity provider to run locally to provide identity services to CanCan running locally.