API cannot be accessed when Cloudflare is active


#1

Hi !

We run an external service that needs access to our woocommerce orders. When Cloudflare is active, we cannot access this API - https://www.medvetenandning.se/wc-api/v3/. When I pause Cloudflre for the site, the API works fine.

Is there a page rule I can add in order to make this API work while having Cloudflare active?

Kindly
/Anders


#2

What kind of error are you seeing when Cloudflare is active?


#3

There probably is. I’d start with the Page Rule match for the URL you posted, then add a bunch of settings to disable and/or bypass various Cloudflare features.

The error @matteo requested will help narrow down which feature you need to disable.


#4

Thanks a lot for your replies !

Sorry that I forgot to include it earlier, the error message I get is:

“Received fatal alert: handshake_failure”

Thanks
/Anders


#5

It seems something correlated to HTTPS. Are you forcing HTTPS on Cloudflare? If so you need to check if the SSL connection type is set to Flexible if you do not have an SSL certificate on your origin.

EDIT: you can use a page rule only on that directory, if you want.


#6

Thanks matteo…not sure about the answer to your question…sorry.

How would the page rule look excatly?


#7

The Page Rule would match https://www.medvetenandning.se/wc-api/v3/* and set SSL to Flexible.

I am seeing this while opening your link, though:

{"store":{"name":"Medveten Andning","description":"Andas B\u00e4ttre - M\u00e5 B\u00e4ttre","URL":"https:\/\/www.medvetenandning.se","wc_version":"3.3.5","version":"3.1.0","routes":{"\/":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/"}},"\/coupons":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/coupons"},"accepts_data":true},"\/coupons\/count":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/coupons\/count"}},"\/coupons\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/coupons\/code\/<code>":{"supports":["HEAD","GET"]},"\/coupons\/bulk":{"accepts_data":true,"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/coupons\/bulk"},"supports":["POST","PUT","PATCH"]},"\/customers":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/customers"},"accepts_data":true},"\/customers\/count":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/customers\/count"}},"\/customers\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/customers\/email\/<email>":{"supports":["HEAD","GET"]},"\/customers\/<id>\/orders":{"supports":["HEAD","GET"]},"\/customers\/<id>\/downloads":{"supports":["HEAD","GET"]},"\/customers\/bulk":{"accepts_data":true,"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/customers\/bulk"},"supports":["POST","PUT","PATCH"]},"\/orders":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/orders"},"accepts_data":true},"\/orders\/count":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/orders\/count"}},"\/orders\/statuses":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/orders\/statuses"}},"\/orders\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/orders\/<order_id>\/notes":{"supports":["HEAD","GET","POST"],"accepts_data":true},"\/orders\/<order_id>\/notes\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/orders\/<order_id>\/refunds":{"supports":["HEAD","GET","POST"],"accepts_data":true},"\/orders\/<order_id>\/refunds\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/orders\/bulk":{"accepts_data":true,"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/orders\/bulk"},"supports":["POST","PUT","PATCH"]},"\/products":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/products"},"accepts_data":true},"\/products\/count":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/products\/count"}},"\/products\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/products\/<id>\/reviews":{"supports":["HEAD","GET"]},"\/products\/<id>\/orders":{"supports":["HEAD","GET"]},"\/products\/categories":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/products\/categories"},"accepts_data":true},"\/products\/categories\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/products\/tags":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/products\/tags"},"accepts_data":true},"\/products\/tags\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/products\/shipping_classes":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/products\/shipping_classes"},"accepts_data":true},"\/products\/shipping_classes\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/products\/attributes":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/products\/attributes"},"accepts_data":true},"\/products\/attributes\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/products\/attributes\/<attribute_id>\/terms":{"supports":["HEAD","GET","POST"],"accepts_data":true},"\/products\/attributes\/<attribute_id>\/terms\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/products\/bulk":{"accepts_data":true,"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/products\/bulk"},"supports":["POST","PUT","PATCH"]},"\/reports":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/reports"}},"\/reports\/sales":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/reports\/sales"}},"\/reports\/sales\/top_sellers":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/reports\/sales\/top_sellers"}},"\/taxes":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/taxes"},"accepts_data":true},"\/taxes\/count":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/taxes\/count"}},"\/taxes\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/taxes\/classes":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/taxes\/classes"},"accepts_data":true},"\/taxes\/classes\/count":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/taxes\/classes\/count"}},"\/taxes\/classes\/<slug>":{"supports":["DELETE"]},"\/taxes\/bulk":{"accepts_data":true,"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/taxes\/bulk"},"supports":["POST","PUT","PATCH"]},"\/webhooks":{"supports":["HEAD","GET","POST"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/webhooks"},"accepts_data":true},"\/webhooks\/count":{"supports":["HEAD","GET"],"meta":{"self":"https:\/\/www.medvetenandning.se\/wc-api\/v3\/webhooks\/count"}},"\/webhooks\/<id>":{"supports":["HEAD","GET","POST","PUT","PATCH","DELETE"],"accepts_data":true},"\/webhooks\/<webhook_id>\/deliveries":{"supports":["HEAD","GET"]},"\/webhooks\/<webhook_id>\/deliveries\/<id>":{"supports":["HEAD","GET"]}},"meta":{"timezone":"Europe\/Stockholm","currency":"SEK","currency_format":"&#107;&#114;","currency_position":"right_space","thousand_separator":"","decimal_separator":".","price_num_decimals":2,"tax_included":false,"weight_unit":"g","dimension_unit":"cm","ssl_enabled":true,"permalinks_enabled":true,"generate_password":false,"links":{"help":"https:\/\/woocommerce.github.io\/woocommerce-rest-api-docs\/"}}}}

It seems to be working for me, the certificate is Cloudflare’s so it’s :orange:. What isn’t working?


#8

Thank you matteo!

// The Page Rule would match https://www.medvetenandning.se/wc-api/v3/* and set SSL to Flexible.
I tried this but got the same error "Received fatal alert: handshake_failure”

Kindly
/Anders


#9

This tells me that the error is probably on the app part, some library fails to support HTTPS, it seems that it’s not supporting the SSL provided by Cloudflare (it need to have SNI) support.

That page rule is therefore useless if this is the case.

Try accessing the same API via a browser (possibly up-to-date).


#10

Thank you matteo, your help is highly appreciated !!!

I’ll pass your info to the developers of the app

/Anders