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

Post Request with SSL doesn’t work (mbedtls error) #59216

Closed
NeroNekro opened this issue Mar 16, 2022 · 5 comments
Closed

Post Request with SSL doesn’t work (mbedtls error) #59216

NeroNekro opened this issue Mar 16, 2022 · 5 comments

Comments

@NeroNekro
Copy link

NeroNekro commented Mar 16, 2022

Godot version

3.4.3

System information

MacOS 12

Issue description

My App make some request to my server. The GET requests works fine and one POST request works too, but my last post request to upload a image in base64 doesn't work.

This error shows up in Xcode:
thirdparty/mbedtls/library/ssl_tls.c:3746: mbedtls_ssl_flush_output() returned -26752 (-0x6880)

I read a problem with lets encrypt and add the certificate from github/godot/thirdparty/certs to my project settings, but it doesn't help.

var query = http_client.query_string_from_dict( {"file": base_64, "format": img.get_format(), "privacy": accepted_privacy, "terms": accepted_term})
var headers = ["Content-Type: application/x-www-form-urlencoded", "Authorization: Bearer "+ connector.token]
print("Try HTTP Request")
$POSTRequest.connect("request_completed", self, "get_upload_status")
var result = $POSTRequest.request(connector.server_url + "upload", headers, connector.ssl, HTTPClient.METHOD_POST, query)
if result != 0:
    print("HTTP Error: " + str(result))

connector.ssl = True
connector.server_url = https://myserver.tld/somepath

On my Testsystem without SSL it works very well.

Steps to reproduce

Make Post Request with a Base64 File

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented Mar 17, 2022

@NeroNekro Please upload a minimal reproduction project to make this easier to troubleshoot.

thirdparty/mbedtls/library/ssl_tls.c:3746: mbedtls_ssl_flush_output() returned -26752 (-0x6880)

This refers to the MBEDTLS_ERR_SSL_WANT_WRITE error code:

/** Connection requires a write call. */
#define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880

@NeroNekro
Copy link
Author

NeroNekro commented Mar 19, 2022

@NeroNekro Please upload a minimal reproduction project to make this easier to troubleshoot.

thirdparty/mbedtls/library/ssl_tls.c:3746: mbedtls_ssl_flush_output() returned -26752 (-0x6880)

This refers to the MBEDTLS_ERR_SSL_WANT_WRITE error code:

/** Connection requires a write call. */
#define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880

I uploaded a test project on google drive.

https://drive.google.com/file/d/1jftSIF-UyOX55_SNZOpL4-Cagkcc3uAW/view?usp=sharing

I had configured a testserver or you change the link in connector.gd.

Server side code:

secure_token = "266d0c79shtsvjsfg7706f25db22d88effa139c01b7f19eea2edf3c6919ee2cf995976d17%="

def check_token(header):
    token = header.split()[1]
    if token == secure_token:
        return True
    else:
        return False

@cat_v1.route("/upload", methods=["POST"])
def upload_cat_image():
    if check_token(request.headers.get('Authorization')):
        image = request.form.get('file')
        filetype = request.form.get('format')
        terms = request.form.get('terms')
        privacy = request.form.get('privacy')
        filename = str(uuid.uuid4())
        with open("api/cat/uploaded_images/" + filename + ".png", "wb") as fh:
            fh.write(base64.b64decode(image))
        ImagesTMP.insert(filename=filename,
                         filenameBackup="",
                         extension=filetype).execute()
        return "{'status': 'yes'}"
    return "{'status': 'no'}"

@Calinou
Copy link
Member

Calinou commented Mar 19, 2022

@NeroNekro Please surround large blocks of text with triple backticks like this:

```
text here
```

This prevents them from taking too much space and also makes sure issue references aren't accidentally created. I edited your comment, but remember to do this next time 🙂

@NeroNekro
Copy link
Author

@NeroNekro Please surround large blocks of text with triple backticks like this:

text here

This prevents them from taking too much space and also makes sure issue references aren't accidentally created. I edited your comment, but remember to do this next time 🙂

yes, of course. sorry for the circumstances.

A few more information:
The server side code is written with python-flask
I renewed all my certificates, but the same error.
On my browser I get the information that the certificate is valid and secure.

@NeroNekro
Copy link
Author

This error message comes up, if the server not responding or something else. Server side fix was the solution. thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants