Flying-Toast / yugo

Yugo is an easy and high-level IMAP client library for Elixir.
https://hex.pm/packages/yugo
MIT License
42 stars 7 forks source link

Problem with ssl_opts, when server and server_name_indication are not the same #25

Open andreas-ementio opened 3 weeks ago

andreas-ementio commented 3 weeks ago

with my email services ssl verification does not work.

the genserver crashes and causes this:

[error] GenServer {Yugo.Registry, :fastmail_client} terminating
** (KeyError) key :next_cmd_tag not found in: nil

If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map
    (yugo 1.0.0) lib/yugo/client.ex:654: Yugo.Client.send_command/3
    (stdlib 4.3.1.5) gen_server.erl:1161: :gen_server.try_terminate/3
    (stdlib 4.3.1.5) gen_server.erl:1351: :gen_server.terminate/10
    (stdlib 4.3.1.5) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

which caused some confusion on my side, though it had to do something with the next_cmd_tag

i think the the cause is that the verification does not work on "imap.fastmail.com", it only works on "fastmail.com"

solutions for that could be:

  1. a method to change the server_name_indication
  2. a custom hostname check like https://github.com/andreas-ementio/yugo/commit/ccca9092e657b07c63c6782453c860005f3e26e1

on a side note: this library handles only receiving new email and not fetching already existing emails in the inbox or am i missing something?

Flying-Toast commented 3 weeks ago

If you send a PR for https://github.com/andreas-ementio/yugo/commit/ccca9092e657b07c63c6782453c860005f3e26e1 I'd be open to merging it.

on a side note: this library handles only receiving new email and not fetching already existing emails in the inbox or am i missing something?

That's correct, my use case for making the library didn't require fetching existing emails. I am not opposed to adding that functionality though - there was even some talk about it in https://github.com/Flying-Toast/yugo/issues/24 but you'd have to check with @bkono on the status of that.

bkono commented 2 weeks ago

Apologies, got pulled off to a different project for a bit and haven't cleaned up / broken down my changes to a place where I was comfortable sending a PR. I just pushed an updated version of the branch currently being used in one of my projects, @andreas-ementio you're welcome to scan the commits I've added and see if there's anything useful in there.

At the moment, it has some needed tweaks to address parsing / tag flowing etc, and a usable implementation of capability listing, mailbox listing, count of messages in a mailbox, mailbox creation, message move support, message fetching ... probably forgetting something else I needed along the way. 😆

Themanwhosmellslikesugar commented 1 week ago

Hi, if it helps anyone, the error with the key :next_cmd_tag not found in: nil can occur due to an old version of OTP. In version <25 there's no :public_key.cacerts_get() function, because of this the client creation fails. I solved this problem by updating OTP to version 25.