403 error when I call the management canister

Hello, when I call the management canister on canisters that I create it gives me a 403. It says I am the controller on ic.rocks and it works to send and get icp with the same principal and with the same agent. Is the management-canister blocking the calls?

@diegop if you have the time, I am looking for a sponse for this question: is the dfx-rust agent the only agent with the current-authorization to call the management-canister and install_code onto new canisters? Are other agents being blocked from installing code onto new canisters?

create_canister can only be called via inter-canister calls. Your wallet, not your principal, is likely to be the controller of your canister. If you want to install code for that canister, you need to ask the wallet to forward install_code call for you. Or you can use dfx to add your principal as the controller of the canister, then you can call install_code directly with your principal.

2 Likes

Thank you, so is the install_code method also only able to be called by cross-canister call? What about for the canister_status method?

Only create_canister and raw_rand are inter-canister only, because both methods need cycles to run. The rest of the methods can be called as ingress message, but you need to be the controller of the canister for most management canister calls.

For some reason when I call the management-canister with this dart-agent it gives me back a 403. I am trying to call the management-canister’s canister_status method and it gives me a 403. It also gives me a 403 when I call the install_code method. I am trying to call it on this canister: bayhi-7yaaa-aaaai-qahca-cai and with this principal: kxmyk-xvfce-zx3tv-azim5-pcehj-sfrcg-qjohx-zdh76-4x6ls-6dlf3-hqe as the caller/controller. You can see on ic.rocks that this principal is the controller of the canister. The dart agent works to send icp with the same kxmyk-principal/controller so I know the signing and ed25519 authorization functions are correct. And the dart-agent works to contact any other canister, only the management canister is giving a 403. I also tried to call the management canister with the agent that dfx uses and then it gave me the correct-sponse. I am thinking that maybe there is some kind of Basic-Auth-token that the dfx agent is sending to the management canister but nothing like that is list in the spec. Do you have any clue what it is?

There is nothing special in dfx, it just makes calls to the management canister either directly or via a wallet. You can see the ic-repl script to see how we install and check status via calls.

My guess is that the dart-agent is not sending the calls as the kxmyk-principal. It’s the same issue with agent-js, you cannot send the message as the dfx principal, as it needs to import the pem file from dfx.

2 Likes

You can check it backwards here is the cbor bytes of a call, you can see the cbor map on cbor.me and check that the sender is the kxmyk-principal and the public-key corresponds to the same kxmyk-principal.
hex-cbor-bytes:
d9d9f7a367636f6e74656e74a76c726571756573745f747970656463616c6c6b63616e69737465725f6964406b6d6574686f645f6e616d656f63616e69737465725f73746174757363617267581c4449444c026d7b6c01b3c4b1f2040001010a0000000000e003d401016673656e646572581da511337dcea0ca19d788874c8b111a0971ef919ffee5fcb9786b2ecf02656e6f6e6365581d01010000010100000000010000010101010001010000000000000001016e696e67726573735f6578706972791b16aa5bedca4321806d73656e6465725f7075626b6579582c302a300506032b6570032100cc6f314161f04826c5a9da2f878a0570bd5f12dfa1af6aa7c9be9c5bf21beda06a73656e6465725f7369675840744e8a3dc6adbc5b135e03300d0ef017150a97b2f744d4339cd19eeec76033bbeda4a45735a1bc2a49d5c7fdcbfb0d65fbb2ee89b4b7c8e745ec6c769785a102

this got a 403.

Do you know what this is used for and how?:
https://docs.rs/ic-agent/0.8.0/ic_agent/agent/http_transport/trait.PasswordManager.html
at this line:
https://docs.rs/ic-agent/0.8.0/src/ic_agent/agent/http_transport.rs.html#130

I forked the rust agent and printed the headers and the bytes and im not seeing anything different between what the dart agent is sending and what the rust agent is sending but the rust agent works and dart agent gets a 403. If someone has an idea of what the dart agent is missing?

Yes it is giving me the same error as if the caller is not the controller but if I backwards check it, the caller is the correct-controller.

Does someone know what this canister is?: Principal ifxlm-aqaaa-multi-pleco-ntrol-lersa-h3ae | ic.rocks