Using "Get Contents of URL" shortcut in HomeKit automations

I'm attempting to send an HTTP request when a motion sensor detects movement. I've setup the trigger in the Home app, and chose "Convert to Shortcut", now I'm trying to get the "Get contents of URL" shortcut action to work.

I'm running the target web server (a little Node.js app) on my local network.

I originally tried to use a simple http server, but was getting the error:

An SSL error has occurred and a secure connection to the server cannot be made.

Assuming that HomeKit was converting my http URL to https automatically I moved my service to a domain where I have LetsEncrypt setup, added support for simple token based auth via headers, and tried again. This time I got the error:

A server with the specified hostname could not be found

I triple checked my spelling, verified that the request worked from my Mac and iOS Safari, then concluded that the HomePod (my current home hub) doesn't do domain name resolution like I expect and I need to use an IP address instead.

Since I can't get a LetsEncrypt cert for a local IP address I generated a self-signed certificate with the instructions outlined here: https://stackoverflow.com/a/24749608 I additionally installed the root CA on all my HomePods and my phone using a "DER format crt" also described in that post. Now I'm getting another error:

The certificate for this server is invalid. You might be connecting to a server that is pretending to be "192.168.7.77" which could put your confidential information at risk.

Installing root certs into my HomePods feels a little reckless, so I'm going to go reset them to factory settings and hope that someone here has some guidance as to what I need to do to make my service eligible for the "Get Contents of URL" shortcut.

Thank you!

A note for anyone trying to reproduce this: the errors I'm quoting are shown when you click the play button at the bottom of the shortcut editing/creation screen ("Home" app > "Automations" tab > "+" button > setup any trigger > "Convert To Shortcut" at the bottom of the action selector > "▶️" button). Clicking "Test automation" after creating the automation, or using the actual Shortcuts app will give misleading results.


  • The question here says "HomeKit automations", but it sounds like the underlying problem is very specific to HomePod, and something being broken with its DNS resolution in "Get Contents of URL"? I found this question while searching for something else and was about to reply with my usual trick for getting LE certificates on LAN-only hostnames before realizing that you needed a cert for an IP address due to the HomePod/DNS issue :).

    Given that this would prevent you from retrieving any public HTTPS URL in this context, it seems like a straightforward bug that should be fixed on Apple's end - have you filed a Feedback for it?

Add a Comment

Accepted Reply

Presumably you have no ability to custom the HTTPS server trust evaluation done by the various subsystems you’re using. In that case your only option is to configure your server with a digital identity whose certificate is trusted by the client. Normally Let’s Encrypt is a good option for this but, as you mentioned, there’s no way to support local addresses in that case. The other option is to run your own CA. I regularly do this using the instructions in QA1948 HTTPS and Test Servers.

As to whether that’s “reckless”, that’s really your decision to make. The only other way I can see out of your conundrum is to host your server on the public Internet, which allows you to use Let’s Encrypt and so on.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
  • @eskimo even using FQDN and Valid Certificate is not working in IOS 16.0.1 and TvOS 16. Any suggestion how to troubleshoot it further. I using Get Content of https://iago.alofis.pet:8087/write?db=Homekit&u=****&p=*** with Post method and posting text(binary file) as this: Homekit,room=bathroom,device=Bathroomsensor occupancy=true

    This is working with no problem from Run button or Test automation but NOT running when is triggered from whatever event in HomeKit.

Add a Comment

Replies

I'm having exactly the same problem, whether I'm using a local internal http server or an external one, whether encrypted or not. In other terms, I've never been able to use the "Get contents of URL" shortcut in a homekit automation. Can anybody confirm that they are using this action and that it works fine?
Exactly the same problem... but months ago it was working properly
Same problem.
the foncrion “get context of URL” return error “A server with the specified hostname could not be found” with any params.
Hi, I'm having the same problem since few days ago. I believe that there is a bug in the URL variable management.
I used a workaround avoiding the usage of the URL variable and pasting the url text directly into the Get contents of URL command; and it seems to work
does anyone resolved this? my workaround worked for one day, and now it seems to be broken again
Same Here.
still exist in 14.3 Beta 2
hub is an iPad

the Testrun in the automation with „get Context of URL“ shotcut worked if it is Done in the Shortcuts App
the Same testrun triggerd from the Home App dosent work on an iOS or iPadOS Device.
and Return “A server with the specified hostname could not be found”

I also valideste the Test on the Home App in macOS 10.15.7 Here the Test of the shortcut succeeded without an error.

Note: it was always the Same automation in all Tests.

so i think its still a Existing Bug in the iOS Home App of Maybe the Home automation Feature the hub uses
Same problem here.

Any URL in the "Get Contents of URL" action of a Shortcut created in the Home app yields an error reading "A server with the specified hostname could not be found".

Hey there! Same problem here. Is there any solution?
Presumably you have no ability to custom the HTTPS server trust evaluation done by the various subsystems you’re using. In that case your only option is to configure your server with a digital identity whose certificate is trusted by the client. Normally Let’s Encrypt is a good option for this but, as you mentioned, there’s no way to support local addresses in that case. The other option is to run your own CA. I regularly do this using the instructions in QA1948 HTTPS and Test Servers.

As to whether that’s “reckless”, that’s really your decision to make. The only other way I can see out of your conundrum is to host your server on the public Internet, which allows you to use Let’s Encrypt and so on.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
  • @eskimo even using FQDN and Valid Certificate is not working in IOS 16.0.1 and TvOS 16. Any suggestion how to troubleshoot it further. I using Get Content of https://iago.alofis.pet:8087/write?db=Homekit&u=****&p=*** with Post method and posting text(binary file) as this: Homekit,room=bathroom,device=Bathroomsensor occupancy=true

    This is working with no problem from Run button or Test automation but NOT running when is triggered from whatever event in HomeKit.

Add a Comment