As of 0.10, Werkzeug doesn't support OpenSSL contexts anymore. This decision was made because it is easier to support ssl.SSLContext across Python versions. Your option to re-write this code is this one:
if __name__ == "__main__":
context = ('cert.crt', 'key.key')
app.run(host='0.0.0.0', port=80, ssl_context=context, threaded=True, debug=True)
See http://werkzeug.pocoo.org/docs/latest/serving/ for all possibilities.
Answer from Markus Unterwaditzer on Stack OverflowProblem running Flask with an ssl_context under Werkzeug 0.10.1
python - SSL wrap socket: AttributeError: 'module' object has no attribute 'wrap_socket' - Stack Overflow
Anvil-uplink for Python >= 3.12 Solves AttributeError: module 'ssl' has no attribute 'wrap_socket' - Show and Tell - Anvil Community Forum
AttributeError("module 'ssl' has no attribute 'wrap_socket'")
Don't name your script ssl.py, because when you name your script ssl.py and you do import ssl you're importing this same script .
Your script is : ssl.py
When you do an import ssl, it calls itself and that is why you get the AttributeError
Give another name to your script and it should work.
OS: Linux Mint 22.1 CinnamonIDE: VS CodePython version: 3.12.3
(apologies for a long post. Half of this is a rant. TL;DR mysql-connector module is installed, but is not connecting due to the SSL having no wrap_socket )
Hey all, this is driving me insane, and its not making sense at all. I'm trying to get MySQL running on my python script and I really want it running...
I've been following the w3schools tutorial on MySQL, and I originally had it connected with no problem. I leave the project to go refactor and maintain my current project. (I didn't touch anything, or install any packages)
When I return, using the same venv and suddenly gives me the error "Module 'ssl' has no attribute 'wrap_socket' " here is the full error. (Pastebin)
Of course, I look up my problem and I find a stack overflow with a similar problem and still not fixed and throwing the same problem. I use pip to uninstall and reinstall mysql-connector-python and still the same problem. I check my installed packages (Pastebin) and its still installed on this venv.
Hell, I even tried the pyOpenSSL and STILL the same problem.
Here's my code:
db = mysql.connector.connect(
host="localhost",
user="me-lol",
password="WpjrslYpjr",
database="VeryCoolDB"
)
# will output when it has
# connected to MySQL server
print("hello world!")If I find a solution, I will share it, so no poor schmuck like me will have to go though this again.