Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`smtps://` email connection string without a port connects to port 25 with no TLS

Đang mở Phù hợp với người mới
#2,697 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend, security

Hướng nghiên cứu

Bắt đầu với src/Exceptionless.Core/Utility/SmtpUri.cs và src/Exceptionless.Core/Configuration/EmailOptions.cs, sau đó lần theo cách tùy chọn mã hóa được tạo ra truyền đến MailKitMailSender. Bổ sung kiểm thử cho smtp://host, smtps://host và smtps://host:587 như mô tả, rồi chạy các kiểm thử liên quan. Hoàn tất khi URI smtps vẫn giữ truyền tải an toàn và chọn đúng cổng cùng chế độ TLS như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

SmtpUri sets port 465 for an smtps:// URI with no explicit port, then overwrites it with 25 a few lines later. Because the encryption default is derived from the port, the mailer then connects to port 25 with no TLS. The parsed IsSecure flag is never used.

Where

  • SmtpUri constructor sets Port = uri.IsDefaultPort ? 465 : uri.Port for smtps, then L41 unconditionally runs Port = uri.IsDefaultPort ? 25 : uri.Port. System.Uri has no default port for smtps, so IsDefaultPort is true and Port is -1 whenever the port is omitted.
  • EmailOptions.ReadFromConfiguration copies host, port, user and password but not IsSecure, and defaults SmtpEncryption from the port via GetDefaultSmtpEncryption (25 maps to None).
  • MailKitMailSender connects with SecureSocketOptions.None and then authenticates.

Steps to reproduce

  1. Set EX_ConnectionStrings__Email=smtps://user:[email protected] (no port) and leave EX_SmtpEncryption unset.
  2. Trigger any email (e.g. a password reset). The mailer connects to smtp.example.com:25 without TLS and sends AUTH with the credentials in the clear, or fails if port 25 is blocked or the server requires TLS.

Expected

smtps://host connects to port 465 with implicit TLS (SslOnConnect). More generally, the smtps scheme should select TLS regardless of port.

Suggested fix

Remove the trailing Port = uri.IsDefaultPort ? 25 : uri.Port; in SmtpUri (the scheme branches already set the port). In EmailOptions, when SmtpEncryption isn't configured and uri.IsSecure is true, default to SSL for port 465 and StartTLS for other ports instead of None. Add SmtpUri tests for smtp://host, smtps://host, and smtps://host:587.

Ngôn ngữ chính
C#
Star
2.5k
Fork
508
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
40

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của exceptionless/Exceptionless

Tất cả issue của exceptionless/Exceptionless

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.