Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cURL error with self signed SSL for local dev #179

Closed
danmaby opened this issue Aug 13, 2018 · 18 comments
Closed

cURL error with self signed SSL for local dev #179

danmaby opened this issue Aug 13, 2018 · 18 comments
Labels
help wanted needs:documentation This requires documentation. type:enhancement New feature or request.
Milestone

Comments

@danmaby
Copy link

danmaby commented Aug 13, 2018

I'm receiving a cURL error 60 when I install the plugin on a multisite locally with a self signed SSL:

screenshot 2018-08-13 00 16 32

The plugin functions as expected when using http://

PHP 7.2
WP 4.9.8 (multisite subdirectory)
Distributor 1.2.2
Local By Flywheel 2.2.4

@jeckman
Copy link
Member

jeckman commented Aug 13, 2018

Are you able to run cURL for other external network connections inside Local by Flywheel?

See http://local.getflywheel.com/community/t/potential-curl-or-ssl-error/7210

@bobbingwide
Copy link

bobbingwide commented Sep 6, 2018

Hi Dan, on a local install trying to use an external connection to another local site I also got the cURL error 60. My workaround was to implement a filter hook to set sslverify to false.

add_filter( "dt_auth_format_get_args", "thugin_dt_auth_format_get_args", 10, 3 );
add_filter( "dt_auth_format_post_args", "thugin_dt_auth_format_get_args", 10, 3 )
function thugin_dt_auth_format_get_args( $args, $context, $thisobj ) {
	$args['sslverify'] = false;
	return $args;
}

Initially I got the following messages.

Limited connection established. Authentication failed.
Push distribution unavailable.
Pull distribution limited to basic content, i.e. title and content body.

but adding the same filter function to two hooks ( get and post ) seems to have resolved the problem.

Note: I am using the application-password plugin.

@dkotter
Copy link
Collaborator

dkotter commented Sep 18, 2018

@danmaby Just wondering if you saw the update above ^? And if so, has that helped? I know I've had to do something similar when working locally on an https site, so hopefully that helps fix the issue.

@jeffpaul
Copy link
Member

jeffpaul commented Jun 6, 2019

@danmaby are you still seeing the cURL error or can we close this issue as resolved?

@jeffpaul jeffpaul added the needs:feedback This requires reporter feedback to better understand the request. label Jun 6, 2019
@bobbingwide
Copy link

bobbingwide commented Jun 6, 2019

@jeffpaul

Dan M. are you still seeing the cURL error or can we close this issue as resolved?

Why do you think this has been resolved? Is there a fix?

@grappler
Copy link
Contributor

grappler commented Jun 7, 2019

Have the same problem on a local vagrant environment.

@jeffpaul
Copy link
Member

jeffpaul commented Jun 7, 2019

@bobbingwide I was curious if @danmaby had been able to resolve it with your instructions, that way I knew more specifically what could resolve his issue within the Distributor codebase.

@jeffpaul
Copy link
Member

jeffpaul commented Jun 7, 2019

@grappler do the edits that @bobbingwide noted solve this for you?

@jeffpaul jeffpaul added type:enhancement New feature or request. and removed needs:feedback This requires reporter feedback to better understand the request. labels Jul 24, 2019
@jeffpaul jeffpaul added this to the 2.0.0 milestone Jul 24, 2019
@jeffpaul
Copy link
Member

@danmaby @grappler were either of you able to try the edits suggested by @bobbingwide on this and confirm this is no longer an issue for you locally?

@jeffpaul jeffpaul added the needs:feedback This requires reporter feedback to better understand the request. label Oct 22, 2019
@grappler
Copy link
Contributor

Setting sslverify to false allows the request to work locally. Just need to figure out next how to have the work only locally.

@bobbingwide
Copy link

@grappler

Just need to figure out next how to have the work only locally.

Do you mean you need to test whether or not the request is being run locally?
I wrote myself an are_you_local method. https://github.com/bobbingwide/oik/blob/7cbf51b9b2e8360aa89ab56bb7a3193470c9cd57/libs/class-oik-remote.php#L779

@grappler
Copy link
Contributor

Do you mean you need to test whether or not the request is being run locally?

I have tested the code locally but I want the connections to ssl verified in production. I think I will be able to work somethings out with the environment constants.

Thanks for sharing your are_you_local method.

@jeffpaul
Copy link
Member

@grappler were you able to get this to work for you locally? If so, it would be great if you could confirm those details so we can add them to our documentation for others to utilize... thanks!

@jeffpaul jeffpaul self-assigned this Nov 21, 2019
@jeffpaul jeffpaul added the needs:documentation This requires documentation. label Nov 21, 2019
@jeffpaul jeffpaul removed their assignment Dec 3, 2019
@jeffpaul
Copy link
Member

jeffpaul commented Dec 5, 2019

@grappler were you able to get this to work for you locally?

2 similar comments
@jeffpaul
Copy link
Member

@grappler were you able to get this to work for you locally?

@jeffpaul
Copy link
Member

jeffpaul commented Jun 8, 2020

@grappler were you able to get this to work for you locally?

@jeffpaul jeffpaul modified the milestones: 1.6.0, 2.0.0 Jun 8, 2020
@jeffpaul jeffpaul added help wanted and removed needs:feedback This requires reporter feedback to better understand the request. labels Nov 12, 2020
@peterwilsoncc
Copy link
Collaborator

peterwilsoncc commented Sep 13, 2022

I'm going to close this off due to lack of response.

For local development, using this as an mu-plugin ought to resolve any issues with self-signed SSL certificates and/or application passwords preventing the use of an HTTP scheme.

Please do not use this in production, it's really not a good idea

<?php

namespace Run\This\In\Local\Development\Only\It\Is\Unsafe;

function application_passwords_available () {
	return true;
}

function no_scheme_errors( $error ) {
	$error->remove( 'invalid_redirect_scheme' );
}

function no_ssl_verify_locally( $args, $url ) {
	$self_signed_hosts = array(
		'//xu-distributor.local/',
		'//ms-distributor.local/',
		'//localhost/',
	);

	foreach( $self_signed_hosts as $host ) {
		if ( strpos( $url, $host ) !== false ) {
			$args['sslverify'] = false;
		}
	}

	return $args;
}

add_filter( 'wp_is_application_passwords_available', 'Run\\This\\In\\Local\\Development\\Only\\It\\Is\\Unsafe\\application_passwords_available' );

add_action( 'wp_authorize_application_password_request_errors', 'Run\\This\\In\\Local\\Development\\Only\\It\\Is\\Unsafe\\no_scheme_errors' );

add_filter( 'http_request_args', 'Run\\This\\In\\Local\\Development\\Only\\It\\Is\\Unsafe\\no_ssl_verify_locally', 10, 2 );

@jeffpaul
Copy link
Member

@peterwilsoncc might it be worth adding that to the Snippets part of the Distributor dev docs site (including the strong DO NOT USE IN PRODUCTION note)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted needs:documentation This requires documentation. type:enhancement New feature or request.
Projects
No open projects
Status: Done
Development

No branches or pull requests

7 participants