mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
require TLS close_notify, add comments
This commit is contained in:
parent
dbfc02318b
commit
5176ff715a
1 changed files with 9 additions and 0 deletions
|
|
@ -433,16 +433,25 @@ impl Page {
|
||||||
certificate: Option<TlsCertificate>,
|
certificate: Option<TlsCertificate>,
|
||||||
) -> impl IsA<IOStream> {
|
) -> impl IsA<IOStream> {
|
||||||
if let Some(certificate) = certificate {
|
if let Some(certificate) = certificate {
|
||||||
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#the-use-of-tls
|
||||||
let tls_connection =
|
let tls_connection =
|
||||||
TlsClientConnection::new(&connection, Some(&connectable)).unwrap(); // @TODO handle
|
TlsClientConnection::new(&connection, Some(&connectable)).unwrap(); // @TODO handle
|
||||||
|
|
||||||
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#client-certificates
|
||||||
tls_connection.set_certificate(&certificate);
|
tls_connection.set_certificate(&certificate);
|
||||||
|
|
||||||
|
// @TODO handle exceptions
|
||||||
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#closing-connections
|
||||||
|
tls_connection.set_require_close_notify(true);
|
||||||
|
|
||||||
// @TODO manual validation
|
// @TODO manual validation
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#tls-server-certificate-validation
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#tls-server-certificate-validation
|
||||||
tls_connection.connect_accept_certificate(move |_, _, _| true);
|
tls_connection.connect_accept_certificate(move |_, _, _| true);
|
||||||
|
|
||||||
|
// Take encrypted I/O stream
|
||||||
tls_connection.upcast::<IOStream>()
|
tls_connection.upcast::<IOStream>()
|
||||||
} else {
|
} else {
|
||||||
|
// Take default I/O stream
|
||||||
connection.upcast::<IOStream>()
|
connection.upcast::<IOStream>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue