# SSL over TCP

#### JGLJGL

##### New Member
Hi, I'm using a TCP connection with a SIM7000 module, but I receive 302 response. So I suposse I need to use SSL over TCP. Any suggestions?

#### unclejed613

##### Well-Known Member
302 is a redirect message...

#### JGLJGL

##### New Member
Yes, but it sends me the redirect message(302) when trying to communicate with www.atesens.com, which has https://. But when trying, for example, with httpbin.org which has http:// it works fine (response 200). So I thought maybe could be something related to SSL certificates.

#### Pommie

##### Well-Known Member
I had this problem about a year ago. If I remember correctly, the redirect is to a page explaining that only https is allowed. I didn't find a solution. I was using an ESP8266. Good luck.

Mike.

#### rjenkinsgb

##### Well-Known Member
If you get a redirect such as a 302, you have to make a new request to whatever URL is given in the 302 data. It will provide a new URL as well as the numeric code.

It just means the URL you must use is not the one you requested. It appears to be a redirect to the login page https://www.atesens.com/login

A web browser would follow the redirect instantly so you would never see that message in the normal course of things.

#### eTech

##### Active Member
Yes, but it sends me the redirect message(302) when trying to communicate with www.atesens.com, which has https://. But when trying, for example, with httpbin.org which has http:// it works fine (response 200). So I thought maybe could be something related to SSL certificates.
Hi

It could be that the site has a URL re-direct enabled. This will provide functionality where a URL typed as http:// will be intercepted and "re-directed" to https:// as a convenience to the user. I used to do this as an ISP in my previous life.

eT

#### JGLJGL

##### New Member
I've tried with https://www.atesens.com/login but also 302 response.

AT+CIPSEND

>

SEND OK
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-length: 0
I've also tried to put http:// instead of https:// but the same error.
Also you may notice that the port I've selected is 80, that because when I select 443 this is the response I get (the other configuration being the same as in the image):
AT+CIPSEND

>

SEND OK

#### eTech

##### Active Member
I've tried with https://www.atesens.com/login but also 302 response.
View attachment 122999

I've also tried to put http:// instead of https:// but the same error.
Also you may notice that the port I've selected is 80, that because when I select 443 this is the response I get (the other configuration being the same as in the image):
why are you connecting to port 80 and then attempting to communicate over port 443?

eT

#### JGLJGL

##### New Member
eTech I have tried diferent options, but also have tried connecting to port 80 and then attempting to communicate over por 80 (http://...).
And also have tried to connet to port 443 and then attempting to communicate over 443 (https://...).

#### eTech

##### Active Member
Try this:
Connect using port 80
Do Get using http login url
When response 302 is returned
Do Get using the url in “location” field of 302 response message.

eT

#### JGLJGL

##### New Member
I add 3 images of the procces, don't know if I've done what you meant.
Anyway, the URL of the web is https://www.atesens.com (or https://www.atesens.com/login in case)

Connect using port 80:

Do Get using http login url :

TCP connection gets closed automaticaly.

Do Get using the url in “location” field of 302 response message:

#### eTech

##### Active Member
hi

not exactly...
the initial GET should be to http://www.atesens.com

the 302 response “location” field will specify where to send the following GET

eT

#### JGLJGL

##### New Member
OK, this is what I get with the initial login:

And looking at "Location", I gues I have to put https:// , but I get the same response.
If I try the https:// with port 443 connection this is what I get, something, a character that can't be read:

#### eTech

##### Active Member
The Web page is temporarily unavailable for unforeseen reasons.

However, the site may be performing a JavaScript redirect.

eT

#### JGLJGL

##### New Member
OK, thank you so much, I'll have a look at it tomorrow.

#### unclejed613

##### Well-Known Member
take the "HTTP/1.0" off the end of the GET string

#### JGLJGL

##### New Member
Hi, I forgot to tell that I made to do both GET and POST in HTTPS. (With that programm, "AT Command Tester").

But not being able to achieve them if trying to send the comands manually for example with "RealTerm" or with a bridge sketch in "Arduino". I get this responsens por GET and POST int HTTPS:
+SHREQ: "POST",400,800
+SHREQ: "GET",400,800

Any idea why it works in one application and not in others?

Here I add the commands I send in case it is helpfull (POST case):
Code:
AT+SHDISC
AT+CGREG?

AT+SAPBR=3,1,"APN","ep.inetd.gdsp"

AT+SAPBR=1,1
AT+CNACT=1,"ep.inetd.gdsp"

AT+SAPBR=2,1
AT+CNACT?

AT+CFSTERM
AT+CFSINIT
AT+CSSLCFG="convert",2,"rapidssl.cer"
AT+SHSSL=1,"rapidssl.cer"

AT+SHCONF="URL","https://www.atesens.com"
AT+SHCONF="BODYLEN",1024
AT+SHCONF="IPVER",0
AT+SHCONF="TIMEOUT",30

AT+SHCONN

AT+SHDISC