how to set up node-http-mitm-proxy (certificate) with Android phone - proxy

My goal is to route and record the traffic from an Android phone (Chrome or my own app) over a proxy. I would like to use this one: https://github.com/joeferner/node-http-mitm-proxy
After configuring my phone's wifi settings (IP and port of desktop machine), and trying to load a page in the mobile chrome, I am now facing a "Your connection is not private" dialog. On the desktop my proxy displays following:
HTTPS_CLIENT_ERROR on : [Error: 8190125312:error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 46
] {
library: 'SSL routines',
function: 'ssl3_read_bytes',
reason: 'sslv3 alert certificate unknown',
code: 'ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN'
}
HTTPS_CLIENT_ERROR on : [Error: 8190125312:error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 46
] {
library: 'SSL routines',
function: 'ssl3_read_bytes',
reason: 'sslv3 alert certificate unknown',
code: 'ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN'
}
HTTPS_CLIENT_ERROR on : [Error: 8190125312:error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 46
] {
library: 'SSL routines',
function: 'ssl3_read_bytes',
reason: 'sslv3 alert certificate unknown',
code: 'ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN'
}
HTTPS_CLIENT_ERROR on : [Error: 8190125312:error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 46
] {
library: 'SSL routines',
function: 'ssl3_read_bytes',
reason: 'sslv3 alert certificate unknown',
code: 'ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN'
}
HTTPS_CLIENT_ERROR on : [Error: 8190125312:error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 46
] {
library: 'SSL routines',
function: 'ssl3_read_bytes',
reason: 'sslv3 alert certificate unknown',
code: 'ERR_SSL_SSLV3_ALERT_CERTIFICATE_UNKNOWN'
}
I guess this is somehow related to certificates, but can someone point me into the right direction of how to solve this issue?
This is how it's done for Charles Proxy: https://stackoverflow.com/a/39227880/457059 I am just clueless about which certificate to install on the Android side in case of using node-http-mitm-proxy

Related

Getting too many request error in Microsoft calendar graph api (429 error code)

error": {
"code": "ExtensionError",
"message": "Operation: Read; Exception: [Status Code: 429; Reason: Resource 'OData_GetSubscription__UserMailbox_f' has reached limit of '250'. Please retry after '2/17/2022 3:53:22 PM']",
}
how can I resolve this error

Poco+OpenSSL, error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

Problem with Poco library (poco-1.9.0-all) and OpenSSL (v1.1.0h from slproweb site).
I can't establish a secure connection with any site.
Simple code:
Poco::Net::initializeSSL();
Poco::Net::Context* pCtx = new Poco::Net::Context(Poco::Net::Context::Usage::TLSV1_2_CLIENT_USE, "", "cacert.pem", "", Poco::Net::Context::VerificationMode::VERIFY_RELAXED, 9, false);
Poco::Net::HTTPSClientSession cs("ya.ru", 443, pCtx);
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, "/?encoding=text", Poco::Net::HTTPMessage::HTTP_1_1);
Poco::Net::HTTPResponse resp;
try
{
Poco::Net::WebSocket sock(cs, req, resp);
}
catch (Poco::Net::SSLException& e)
{
cout << "ssl exception: " << e.displayText() << endl;
}
catch (...)
{
}
I get a exception from the poco library: 'SSL Exception: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed'.
File cacert.pem downloaded from https://curl.haxx.se/docs/caextract.html
OpenSSL reads it without errors by SSL_CTX_use_certificate_chain_file function in Poco::Net::Context::init(const Params& params).
If I specify the verification mode VERIFY_NONE in Poco::Net::Context constructor - connection passes without problems.
Maybe I'm setting the wrong parameters in Poco::Net::Context constructor?
I have the same exception: SSL Exception: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed. Changing the order of constructor Poco::Net::Context constructor arguments helps:
Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "cacert.pem", Poco::Net::Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:#STRENGTH");
cacert.pem it is the root CA certificate file and should be passed as caLocation argument.

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages

In my Laravel project, I am using the laravelgooglemaps api by farhanwazir on my "contact us" page to display a fixed location.
Route for contactus page:
Route::get('/contactus', function () {
$config['center'] = 'California State University, Fullerton';
$config['zoom']='15';
$config['map_height'] = "300px";
$config['map_width'] = "300px";
$config['scrollwheel']= false;
GMaps::initialize($config);
$marker['position'] = 'California State University, Fullerton';
$marker['infowindow_content'] = 'Easywash Centre';
GMaps::add_marker($marker);
$map = GMaps::create_map();
return view('contactus')->with('map', $map); });
In my contactus.blade.php file:
{!! $map['html'] !!}
But sometimes when I load the "contact us" page I get the error:
ErrorException (E_WARNING)
file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Can anyone help me understand why I am getting such error and how it can be solved?
Try this:
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
file_get_contents($link, false, stream_context_create($arrContextOptions));
Just in case anyone wondering I solved this error by changing https:// to http:// .

Error: connect ECONNREFUSED 127.0.0.1:9200 ElasticSearch Firebase

From the firebase elastic search project flashlight: https://github.com/firebase/flashlight.git
I imported data from example/seed/data.json into my https://flashlighttest.firebaseio.com
I run this in root:
FB_NAME="flashlighttest" node app.js
I got this error.
failed to index firebase/user/bruce: Error: connect ECONNREFUSED 127.0.0.1:9200
failed to index firebase/user/chan: Error: connect ECONNREFUSED 127.0.0.1:9200
failed to index firebase/user/chuck: Error: connect ECONNREFUSED 127.0.0.1:9200
failed to index firebase/user/kaiso: Error: connect ECONNREFUSED 127.0.0.1:9200
failed to index firebase/user/kato: Error: connect ECONNREFUSED 127.0.0.1:9200
failed to index firebase/user/musashi: Error: connect ECONNREFUSED 127.0.0.1:9200
{ Error: connect ECONNREFUSED 127.0.0.1:9200
at Object.exports._errnoException (util.js:1007:11)
at exports._exceptionWithHostPort (util.js:1030:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9200 }
{ Error: connect ECONNREFUSED 127.0.0.1:9200
at Object.exports._errnoException (util.js:1007:11)
at exports._exceptionWithHostPort (util.js:1030:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9200 }
{ Error: connect ECONNREFUSED 127.0.0.1:9200
at Object.exports._errnoException (util.js:1007:11)
at exports._exceptionWithHostPort (util.js:1030:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9200 }
After, i run serve in the example folder and open http://localhost:3000/. Then, any words that I searched, I got 0 result with this error.
{
"error": {
"address": "127.0.0.1",
"code": "ECONNREFUSED",
"errno": "ECONNREFUSED",
"port": 9200,
"syscall": "connect"
},
"total": 0
}
I know that this error happens in lib/PathMonitor.js the _childAdded function.
_childAdded: function(key, data) {
var name = nameFor(this, key);
this.esc.index(this.index, this.type, data, key)
.on('data', function(data) {
console.log('indexed'.green, name);
})
.on('error', function(err) {
console.error('failed to index %s: %s'.red, name, err);
})
.exec();
},
Can someone tell me of what went wrong?
Thanks
This happens because ElasticSearch is not running in my localhost. After I download the elasticsearch and run bin/elasticsearch everything is working fine.

Unable to get Youtube stats (views) with Google API SDK or with just key

I am trying to access the numbers of views from my youtube videos. I used to use the v2 of the Google API for Youtube stats. But for some reason nothing I try works.
First I tried using the API Explorer given by Google. It worked... It generated this request:
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DU9999999&start-date=2015-05-01&end-date=2015-05-01&metrics=views&dimensions=video&filters=video%3D%3D6cBs8212oyI&key={YOUR_API_KEY}
So I tried it in curl with the key I created in Google API Console I also activated Youtube API and Youtube API Stats...
But when I curl it I get this error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I have no idea what this means...
So now I tried with Google SDK.
I am able to get this:
{
"access_token":"--------",
"expires_in":3600,
"created":1431449678
}
But then I get this error:
Fatal error: Uncaught exception 'Google_Service_Exception' with
message 'Error calling GET
https://www.googleapis.com/analytics/v3/data/ga?ids=channel%3D%0000000&start-date=2015-05-01&end-date=2015-05-01&metrics=views&filters=video%3D%3D6cBs8212oyI:
(403) Insufficient Permission' in
/------/google-api-php-client/src/Google/Http/REST.php:111
Stack trace: #0
/--------/google-api-php-client/src/Google/Http/REST.php(63):
Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request),
Object(Google_Client)) #1 [internal function]:
Google_Http_REST::doExecute(Object(Google_Client),
Object(Google_Http_Request)) #2
/--------/google-api-php-client/src/Google/Task/Runner.php(172):
call_user_func_array(Array, Array) #3
/--------/google-api-php-client/src/Google/Http/REST.php(47):
Google_Task_Runner->run() #4
/------/google-api-php-client/src
in
/-------/google-api-php-client/src/Google/Http/REST.php
on line 111
So this seems to be the issue:
(403) Insufficient Permission
I tried to find what was causing this but to no avail.
Again this requests works in Google explorer found on this page: https://developers.google.com/youtube/analytics/v1/
Here is the code I use for requesting my Youtube views:
try {
$key = file_get_contents($key_file_location);
if( $key === false )
throw new Exception('Failed to open/read p12 key file.');
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array('https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/yt-analytics.readonly'),
$key
);
$client->setAssertionCredentials($cred);
// Check if the token is out of date
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
// Reset the service_token in the PHP session
echo $_SESSION['service_token'] = $client->getAccessToken();
} catch (Exception $e) {
//getStatsMailError( 'Caught exception: ' . $e->getMessage() );
error_log($e->getMessage());
}
//Option Paramaters
$optParams = array(
'filters' => 'video==6cBs8212oyI',
);
$result = $service->data_ga->get($channel_id, '2015-05-01', '2015-05-01', 'views', $optParams);
The rest works because I am able to get the access_token.

Resources