# Can we run https calls in canister with ip address directly?

**URL:** <https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568>\
**Category:** Developers\
**Tags:** Discussing\
**Created:** [March 18, 2024, 12:09pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568 "2024-03-18T12:09:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![q2333gh](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/q2333gh/32/36020_2.png) [@q2333gh](https://forum.dfinity.org/u/q2333gh)\
**Post date:** [March 18, 2024, 12:09pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/1 "2024-03-18T12:09:47Z")

</div>

```rust
// 
#[ic_cdk::update]
pub async fn get_payload_from_my_server(
) -> String {
  let url = "https://1.2.3.4:8002/file/file/ret_to_res_body/payload_02.json";
  let request = CanisterHttpRequestArgument {
    url: url.to_string(),
    max_response_bytes: None, //optional for request
    method: HttpMethod::POST,
    headers: Vec::new(),
    body: None,
    transform: None, //optional for request
  };

  let cycles = 1 * TERA;

  match http_request(request, cycles).await {
    Ok((response,)) => {
      let mut str_body = String::from_utf8(response.body)
        .expect("Transformed response is not UTF-8 encoded.");
      str_body = str_body.replace("\\", "");
      str_body
    }
    Err((r, m)) => {
      let message =
      format!("The http_request resulted into error. RejectionCode: {r:?}, Error: {m}");
      message
    }
  }
}

```

`dfx canister call backend get_payload_from_my_server `

return:

“The http\_request resulted into error. RejectionCode: SysTransient, Error: Connecting to 1.2.3.4 failed: Request failed direct connect error trying to connect: invalid peer certificate: UnknownIssuer and connect through socks error trying to connect: dns error: failed to lookup address information: Name or service not known”,

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [March 18, 2024, 12:17pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/2 "2024-03-18T12:17:50Z")

</div>

Given that IPv6 is required for HTTP outcalls, I would guess that’s why it fails with `1.2.3.4`. However, based on your stack trace, it also seems the SSL certificate is not recognized for your call.

---

<div class="post-metadata">

**Author:** ![q2333gh](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/q2333gh/32/36020_2.png) [@q2333gh](https://forum.dfinity.org/u/q2333gh)\
**Post date:** [March 18, 2024, 12:24pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/3 "2024-03-18T12:24:08Z")

</div>

Yes. i use self ssl certification:

this cmd can get respon.body data :  
wget -v -O- https://\<a\_ip\_v4\_addr\>:8002/file/file/ret\_to\_res\_body/  
payload\_02.json --no-check-certificate

---

<div class="post-metadata">

**Author:** ![q2333gh](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/q2333gh/32/36020_2.png) [@q2333gh](https://forum.dfinity.org/u/q2333gh)\
**Post date:** [March 18, 2024, 12:24pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/4 "2024-03-18T12:24:56Z")

</div>

allright. i will try to get a ipv6 addr firstly

---

<div class="post-metadata">

**Author:** ![q2333gh](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/q2333gh/32/36020_2.png) [@q2333gh](https://forum.dfinity.org/u/q2333gh)\
**Post date:** [March 18, 2024, 12:25pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/5 "2024-03-18T12:25:58Z")

</div>

The higher problem is that i actually want to send a file to my rust canister on ic.  
Only get this solution yet. If there is any better way will be great.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [March 18, 2024, 12:46pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/6 "2024-03-18T12:46:20Z")

</div>

Don’t know about your use case, just wanted to shared the above information given it seemed related to the error you were facing.

---

<div class="post-metadata">

**Author:** ![q2333gh](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/q2333gh/32/36020_2.png) [@q2333gh](https://forum.dfinity.org/u/q2333gh)\
**Post date:** [March 18, 2024, 1:16pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/7 "2024-03-18T13:16:34Z")

</div>

Solved by learning this code hah.

> <https://github.com/open-chat-labs/open-chat/issues/5570>
>
> I searched for source code but not found out. 
> Its a very useful function in ca…nister !
> !\[image\](https://github.com/open-chat-labs/open-chat/assets/32679742/fe7a6057-b280-4eb2-8505-2514b4b95840)

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [March 18, 2024, 1:24pm UTC](https://forum.dfinity.org/t/can-we-run-https-calls-in-canister-with-ip-address-directly/28568/8 "2024-03-18T13:24:50Z")

</div>

Gotcha. Funny enough it’s the same approach I had to implement in my “Juno \<\> OpenAI” demo to pass a file to the Vision Preview API.

> <https://github.com/peterpeterparker/juno-openai/blob/0bc9efe2e8da0ef761e5685e1482d9e9fc52c055/app/src/satellite/src/lib.rs#L79>

Great to hear you solved it!
