Swift SSL error names the host "unknown host" for some addresses

Open Beginner friendly
#1,759 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust, swift

Research direction

Read native/swift/Sources/wordpress-api/SafeRequestExecutor.swift around line 218 and compare its host lookup with buildURLRequest and wpEndpointUrlRfc3986(url:), referenced in the issue as the approach used since #1746. Check how percent escapes should be decoded for display. Done means the certificate mismatch error names affected hosts instead of showing "unknown host".

Written by the indexing model from the issue text.

Description

Error Handling Swift

The Swift executor's certificate-mismatch error can name the host as "unknown host".

What happens

The SSL error handler in native/swift/Sources/wordpress-api/SafeRequestExecutor.swift (around line 218) reads the host with URL(string: request.url())?.host ?? "unknown host". It uses the unencoded address, which URL(string:) rejects for a host containing {, }, " or ` on every OS version, and for | or ^ anywhere before iOS 17 and macOS 14.

Who is affected

Only the wording of a CertificateNotValidForName error for those addresses. It can't crash.

Suggested fix

Read the host from the RFC 3986 form, as buildURLRequest does since #1746 (wpEndpointUrlRfc3986(url:)), and decode its percent escapes for display.

Dominant language
Rust
Stars
38
Forks
6
Avg merge
2d 3h
Merged PRs (30d)
50

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/wordpress-rs

All issues in Automattic/wordpress-rs

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.