bernhard Posted October 22, 2022 Share Posted October 22, 2022 Hi everyone! I'm having troubles developing an API... $http = $this->wire(new WireHttp()); $http->get("my.example.com"); db($http->getResponseHeaders()); This returns the following: array 'date' => 'Sat, 22 Oct 2022 18:27:02 GMT' 'server' => 'Apache' 'location' => 'https://my.example.com/' 'content-length' => '238' 'content-type' => 'text/html; charset=iso-8859-1' my.example.com is setup to redirect from HTTP to HTTPS via 301 $http->getHttpCode() Returns 301 for ->get("my.example.com") 301 for ->get("http://my.example.com") 0 for ->get("https://my.example.com") I'd expect it to return 200 for HTTPS, or am I missing something? Thx! Link to comment Share on other sites More sharing options...
BitPoet Posted October 22, 2022 Share Posted October 22, 2022 Might be from an unsuccessful curl request (stuff like incompatible cipher suites, untrusted certificate etc.). Have you checked $http->getError()? 2 Link to comment Share on other sites More sharing options...
bernhard Posted October 22, 2022 Author Share Posted October 22, 2022 Interesting... It works for www.baumrock.com but not for test2.gemeindeguru.at $http = $this->wire(new WireHttp()); $http->get("www.baumrock.com"); db($http->getResponseHeaders()); db($http->getHttpCode()); $http->get("test2.gemeindeguru.at"); db($http->getResponseHeaders()); db($http->getHttpCode()); any ideas? Link to comment Share on other sites More sharing options...
bernhard Posted October 22, 2022 Author Share Posted October 22, 2022 Sorry, checked getErrors() instead of getError() so I thought that did not help! Here is the error: 2: fsockopen(): php_network_getaddresses: getaddrinfo for failed: Name or service not known, 2: fsockopen(): Unable to connect to :80 (php_network_getaddresses: getaddrinfo for failed: Name or service not known), 0: php_network_getaddresses: getaddrinfo for failed: Name or service not known What does that mean? Link to comment Share on other sites More sharing options...
BitPoet Posted October 22, 2022 Share Posted October 22, 2022 A bit of a stab in the dark, but maybe an IPV6 issue? I can see that the test2 host has an IPV6 address while the other does not. Link to comment Share on other sites More sharing options...
Jan Romero Posted October 22, 2022 Share Posted October 22, 2022 Not at a computer right now, but the error should have the host name in it (where the two spaces collide instead, and before the :80 port). Apparently something went wrong inside wireHttp->get() where it parses the url string. Indeed, url_parse() doesn’t return the right components when given "test2.gemeindeguru.at". I think you’re required to pass the url including the protocol. 1 Link to comment Share on other sites More sharing options...
Jan Romero Posted October 22, 2022 Share Posted October 22, 2022 I think the problem is here https://github.com/processwire/processwire/blob/924f93214536a506babbce1bab5c6c9e2093fc1e/wire/core/WireHttp.php#L471 See how it sanitizes the url at the top of the function. That’s where it prepends the scheme if necessary. Curl and fopen are called with that sanitized url, but your error came from the "socket" method, which seems to be called with the unsanitized url. I’m probably missing something, but I’m not going to look into this any more deeply from my phone ? 1 1 Link to comment Share on other sites More sharing options...
bernhard Posted October 23, 2022 Author Share Posted October 23, 2022 Hey guys thx for your help. I've changed the line in question to $url and now I get this: The certificate is a letsencrypt wildcard cert. I'm totally blank on that topic - is there anything I can do about that? Or is it an issue with WireHttp? Link to comment Share on other sites More sharing options...
bernhard Posted October 23, 2022 Author Share Posted October 23, 2022 Update: I tried using Guzzle and also get an error. My research shows that it seems to be a server setup issue! I'll keep you posted - thx for your help so far! Link to comment Share on other sites More sharing options...
Jan Romero Posted October 23, 2022 Share Posted October 23, 2022 Maybe this helps? https://whatsmychaincert.com/?test2.gemeindeguru.at I wish I knew more about this stuff ? 1 Link to comment Share on other sites More sharing options...
bernhard Posted January 1, 2023 Author Share Posted January 1, 2023 Today I had to renew the certificate. Unfortunately that can't be done automatically as the challenge relies on DNS records that have to be created. But it's not a lot of work and only has to be done every 3 months, so it's fine. When renewing the cert I realised that the CA Authority was not properly setup. Now with the new cert everything is green and I get the correct status-code ? Thx for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now