Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
RustPython/crates/stdlib/src/ssl/error.rs at typelock · RustPython/RustPython · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
RustPython
/
RustPython
Public
Notifications
You must be signed in to change notification settings
Fork
1.5k
Star
22.3k
Code
Issues
295
Pull requests
100
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Files
Expand file tree
typelock
Breadcrumbs
RustPython
/
crates
/
stdlib
/
src
/
ssl
/
error.rs
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
146 lines (128 loc) · 4.5 KB
typelock
Breadcrumbs
RustPython
/
crates
/
stdlib
/
src
/
ssl
/
error.rs
Copy path
Top
File metadata and controls
Code
Blame
146 lines (128 loc) · 4.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// SSL exception types shared between ssl (rustls) and openssl backends
pub
(
crate
)
use
ssl_error
::
*
;
#
[
pymodule
(
sub
)
]
pub
(
crate
)
mod
ssl_error
{
use
crate
::
vm
::
{
Py
,
PyPayload
,
PyRef
,
PyResult
,
VirtualMachine
,
builtins
::
{
PyBaseException
,
PyOSError
,
PyStrRef
}
,
types
::
Constructor
,
}
;
// Error type constants - exposed as pyattr and available for internal use
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_NONE
:
i32
=
0
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_SSL
:
i32
=
1
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_WANT_READ
:
i32
=
2
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_WANT_WRITE
:
i32
=
3
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_WANT_X509_LOOKUP
:
i32
=
4
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_SYSCALL
:
i32
=
5
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_ZERO_RETURN
:
i32
=
6
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_WANT_CONNECT
:
i32
=
7
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_EOF
:
i32
=
8
;
#
[
pyattr
]
pub
(
crate
)
const
SSL_ERROR_INVALID_ERROR_CODE
:
i32
=
10
;
#
[
pyattr
]
#
[
pyexception
(
name =
"SSLError"
,
base =
PyOSError
)
]
#
[
derive
(
Debug
)
]
#
[
repr
(
transparent
)
]
pub
struct
PySSLError
(
PyOSError
)
;
#
[
pyexception
]
impl
PySSLError
{
// Returns strerror attribute if available, otherwise str(args)
#
[
pymethod
]
fn
__str__
(
exc
:
&
Py
<
PyBaseException
>
,
vm
:
&
VirtualMachine
)
->
PyResult
<
PyStrRef
>
{
use
crate
::
vm
::
AsObject
;
// Try to get strerror attribute first (OSError compatibility)
if
let
Ok
(
strerror
)
= exc
.
as_object
(
)
.
get_attr
(
"strerror"
,
vm
)
&& !vm
.
is_none
(
&
strerror
)
{
return
strerror
.
str
(
vm
)
;
}
// Otherwise return str(args)
let
args = exc
.
args
(
)
;
if
args
.
len
(
)
==
1
{
args
.
as_slice
(
)
[
0
]
.
str
(
vm
)
}
else
{
args
.
as_object
(
)
.
str
(
vm
)
}
}
}
#
[
pyattr
]
#
[
pyexception
(
name =
"SSLZeroReturnError"
,
base =
PySSLError
)
]
#
[
derive
(
Debug
)
]
#
[
repr
(
transparent
)
]
pub
struct
PySSLZeroReturnError
(
PySSLError
)
;
#
[
pyexception
]
impl
PySSLZeroReturnError
{
}
#
[
pyattr
]
#
[
pyexception
(
name =
"SSLWantReadError"
,
base =
PySSLError
,
impl
)
]
#
[
derive
(
Debug
)
]
#
[
repr
(
transparent
)
]
pub
struct
PySSLWantReadError
(
PySSLError
)
;
#
[
pyattr
]
#
[
pyexception
(
name =
"SSLWantWriteError"
,
base =
PySSLError
,
impl
)
]
#
[
derive
(
Debug
)
]
#
[
repr
(
transparent
)
]
pub
struct
PySSLWantWriteError
(
PySSLError
)
;
#
[
pyattr
]
#
[
pyexception
(
name =
"SSLSyscallError"
,
base =
PySSLError
,
impl
)
]
#
[
derive
(
Debug
)
]
#
[
repr
(
transparent
)
]
pub
struct
PySSLSyscallError
(
PySSLError
)
;
#
[
pyattr
]
#
[
pyexception
(
name =
"SSLEOFError"
,
base =
PySSLError
,
impl
)
]
#
[
derive
(
Debug
)
]
#
[
repr
(
transparent
)
]
pub
struct
PySSLEOFError
(
PySSLError
)
;
#
[
pyattr
]
#
[
pyexception
(
name =
"SSLCertVerificationError"
,
base =
PySSLError
,
impl
)
]
#
[
derive
(
Debug
)
]
#
[
repr
(
transparent
)
]
pub
struct
PySSLCertVerificationError
(
PySSLError
)
;
// Helper functions to create SSL exceptions with proper errno attribute
pub
fn
create_ssl_want_read_error
(
vm
:
&
VirtualMachine
)
->
PyRef
<
PyOSError
>
{
vm
.
new_os_subtype_error
(
PySSLWantReadError
::
class
(
&
vm
.
ctx
)
.
to_owned
(
)
,
Some
(
SSL_ERROR_WANT_READ
)
,
"The operation did not complete (read)"
,
)
}
pub
fn
create_ssl_want_write_error
(
vm
:
&
VirtualMachine
)
->
PyRef
<
PyOSError
>
{
vm
.
new_os_subtype_error
(
PySSLWantWriteError
::
class
(
&
vm
.
ctx
)
.
to_owned
(
)
,
Some
(
SSL_ERROR_WANT_WRITE
)
,
"The operation did not complete (write)"
,
)
}
pub
fn
create_ssl_eof_error
(
vm
:
&
VirtualMachine
)
->
PyRef
<
PyOSError
>
{
vm
.
new_os_subtype_error
(
PySSLEOFError
::
class
(
&
vm
.
ctx
)
.
to_owned
(
)
,
Some
(
SSL_ERROR_EOF
)
,
"EOF occurred in violation of protocol"
,
)
}
pub
fn
create_ssl_zero_return_error
(
vm
:
&
VirtualMachine
)
->
PyRef
<
PyOSError
>
{
vm
.
new_os_subtype_error
(
PySSLZeroReturnError
::
class
(
&
vm
.
ctx
)
.
to_owned
(
)
,
Some
(
SSL_ERROR_ZERO_RETURN
)
,
"TLS/SSL connection has been closed (EOF)"
,
)
}
pub
fn
create_ssl_syscall_error
(
vm
:
&
VirtualMachine
,
msg
:
impl
Into
<
String
>
,
)
->
PyRef
<
PyOSError
>
{
vm
.
new_os_subtype_error
(
PySSLSyscallError
::
class
(
&
vm
.
ctx
)
.
to_owned
(
)
,
Some
(
SSL_ERROR_SYSCALL
)
,
msg
.
into
(
)
,
)
}
}
You can’t perform that action at this time.