Skip to content

I'm having problem with https websites #87

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

Open
gomezramones opened this issue May 24, 2020 · 7 comments
Open

I'm having problem with https websites #87

gomezramones opened this issue May 24, 2020 · 7 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@gomezramones
Copy link

gomezramones commented May 24, 2020

Hi, I'm trying to stablish communication with a server that uses https but without sucess. I have been striving to login to that server but without success.. This is how I do it

HttpClient http(client1,serverAddress);
const int kNetworkTimeout = 3*1000;
// Number of milliseconds to wait if no data is available before trying again
const int kNetworkDelay = 1000;

void Get_token(){
  http.beginRequest();
  http.post("/api/auth/login","application/json", "");
  http.sendHeader("Authorization","Basic c2XBzaXNfdTpmNFgwXktpVjZKQlEzy");
  http.endRequest()
  
  int statusAuth = http.responseStatusCode();
  String response = http.responseBody();
  Serial.print("Response: ");
  Serial.println(response);
  Serial.print("Status response:");
  Serial.println(statusAuth);
}

void setup(){
  Serial.begin(115200);
  Serial2.begin(115200);
  conexionsim();
  conexionred();
  Get_token();
}

I always receive -3, which is timeout

@zaindroid
Copy link

I am having the same issue. Its seems like httpClient.connect() is not able to connect to server. I am not sure if I am using the right server address in my code but I have tried with so many different ways but every time i get -3 response

@gomezramones
Copy link
Author

gomezramones commented Jun 2, 2020

I think the problem is this library doesn't handle https website. You might try with an API to connect to your server and see if the address is ok. I could solve the problem by stablishing communication between my SIM5360 and my server https://... enabling https comunication of my module with AT commands. Although at the beginning it was sending me an 301 error (moved permanently) and it was because this type of module (maybe also de this library) doesn't handle redirected as many api or libraries (like in python)

@bricemiramont
Copy link

Hi, try to create your client like that (for standard SSL port 443):
HttpClient client = HttpClient(wifi, server, 443);

replace wifi with the network connection you use AND in the case of wifi, create your wifi object instance as SSL like this:
WiFiSSLClient wifi;

@zaindroid
Copy link

zaindroid commented Jun 23, 2020 via email

@gomezramones
Copy link
Author

What module or chip are you using to connect to the internet? It is imposible to make it work with that statement because Https have to make some certification some staffs that library doesn't do it. If you have a quectec or simcom chip you can enable SSL so the chip carries out all the SSL task

@takkaO
Copy link

takkaO commented Jun 6, 2023

A similar problem occurred with a program that posts to Google Spread Sheet with ESP32.
Two steps were required to solve the problem.

  • Use WiFiClientSecure instead of WiFiClient.
  • If CA is not set, call setInsecure function (i.d. client.setInsecure() )

I hope this helps someone.
Thank you.

@SergioArrighi
Copy link

SergioArrighi commented Apr 8, 2024

I am experiencing some difficulties too with HTTPS connections.
I have a self signed certificate and CA.

If I execute openssl verify -CAfile ca.crt 192.168.1.10.crt
I get OK.

I use WiFiClientSecure and call setCACert
But I always have this error:

[  3896][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():278]: (-9984) X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
[  3899][E][WiFiClientSecure.cpp:135] connect(): start_ssl_client: -9984

If I use setInsecure everything works fine.

I am investigating this issue.

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

7 participants
@per1234 @SergioArrighi @zaindroid @bricemiramont @gomezramones @takkaO and others