September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -0,0 +1,6 @@
|
|||
using HTTP, MbedTLS
|
||||
|
||||
conf = MbedTLS.SSLConfig(true, log_secrets="/utl/secret_key_log.log")
|
||||
resp = HTTP.get("https://httpbin.org/ip", sslconfig=conf)
|
||||
|
||||
println(resp)
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# cert creation commands
|
||||
|
||||
# openssl req -newkey rsa:4096 -keyout my_key.pem -out my_csr.pem -nodes -subj "/CN=ME"
|
||||
|
||||
# openssl x509 -req -in my_csr.pem -signkey my_key.pem -out my_cert.pem
|
||||
|
||||
use v6;
|
||||
use OpenSSL;
|
||||
|
||||
my $host = "github.com";
|
||||
|
||||
my $ssl = OpenSSL.new(:client);
|
||||
|
||||
$ssl.use-certificate-file("./my_cert.pem");
|
||||
$ssl.use-privatekey-file("./my_key.pem");
|
||||
$ssl.check-private-key;
|
||||
|
||||
|
||||
my $s = IO::Socket::INET.new(:$host, :port(443));
|
||||
|
||||
$ssl.set-socket($s);
|
||||
$ssl.set-connect-state;
|
||||
$ssl.connect;
|
||||
$ssl.write("GET / HTTP/1.1\r\n\r\n");
|
||||
say $ssl.read(1024);
|
||||
$ssl.close;
|
||||
$s.close;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
require 'uri'
|
||||
require 'net/http'
|
||||
|
||||
uri = URI.parse('https://www.example.com')
|
||||
pem = File.read("/path/to/my.pem")
|
||||
cert = OpenSSL::X509::Certificate.new(pem)
|
||||
key = OpenSSL::PKey::RSA.new(pem)
|
||||
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true,
|
||||
cert: cert, key: key) do |http|
|
||||
request = Net::HTTP::Get.new uri
|
||||
http.request request
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue