Cannot create a client socket with a PROTOCOL_TLS_SERVER context while trying to rank a player in-group
Asked Answered
E

2

2
import robloxapi

async def grouprank(userId, rankName):
    # omitted rank-name to role id mapping
    rankId = dic[rankName]
    client = robloxapi.Client(cookie=NOT_STUPID_ENOUGH_TO_DISCLOSE)
    grp = await client.get_group(32409863)
    await robloxapi.client.Group.set_rank_by_id(grp, userId, rankId)

import asyncio
lp = asyncio.new_event_loop()
lp.run_until_complete(grouprank(2315210162, "Recruit"))

The code above throws the following error: ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:795)

This code is mainly to rank a player to another rank in a roblox group using a bot

Edo answered 21/5, 2023 at 2:52 Comment(0)
I
2

This is a known issue in the ssl library and there are MANY GitHub issues based on this. For example, this one is a sample issue. For me, it worked by using ssl._create_default_https_context = ssl._create_unverified_context in previous projects. Idk if it will work for Roblox because I don't have access to it.

Istic answered 21/5, 2023 at 8:43 Comment(1)
It did not work for roblox but it's the best answer available here.Edo
C
0

For me, this error message was caused by using ssl.Purpose.CLIENT_AUTH instead of ssl.Purpose.SERVER_AUTH in my ssl.create_default_context() arguments. Clients should use ssl.Purpose.SERVER_AUTH because they are authorizing the servers they are communicating with, not ssl.Purpose.CLIENT_AUTH, and vice versa for servers.

import socket
import ssl
ME_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sslContext = ssl.create_default_context(purpose = ssl.Purpose.SERVER_AUTH, cafile = 'C://...//CACert.pem', capath = None, cadata = None)
sslContext.load_cert_chain(certfile = 'C://...//serverCert.pem')
ME_SSL = sslContext.wrap_socket(ME_socket, server_side = False, server_hostname = 'MY_IP')
Chessboard answered 12/8 at 19:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.