added some example sketchs
This commit is contained in:
parent
720735b496
commit
88d4061496
5 changed files with 536 additions and 1 deletions
152
examples/EthernetHTTPS/EthernetHTTPS.ino
Normal file
152
examples/EthernetHTTPS/EthernetHTTPS.ino
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
Web client
|
||||
|
||||
This sketch connects to a website (http://www.arduino.cc/asciilogo.txt)
|
||||
using an Arduino Wiznet Ethernet shield.
|
||||
|
||||
Circuit:
|
||||
* Ethernet shield attached to pins 10, 11, 12, 13
|
||||
|
||||
created 18 Dec 2009
|
||||
by David A. Mellis
|
||||
modified 9 Apr 2012
|
||||
by Noah Koontz, based on work by Adrian McEwen and Tom Igoe
|
||||
|
||||
*/
|
||||
|
||||
// NOTE: The Ethernet library MUST be modified to use this example!
|
||||
// For more detailed instructions check out https://github.com/OPEnSLab-OSU/SSLClient#sslclient-with-ethernet
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SSLClient.h>
|
||||
#include "trust_anchors.h"
|
||||
|
||||
// Enter a MAC address for your controller below.
|
||||
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
|
||||
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
|
||||
|
||||
// if you don't want to use DNS (and reduce your sketch size)
|
||||
// use the numeric IP instead of the name for the server:
|
||||
//IPAddress server(54,85,55,79); // numeric IP for Google (no DNS)
|
||||
const char server[] = "www.arduino.cc"; // name address for Arduino (using DNS)
|
||||
const char server_host[] = "www.arduino.cc"; // leave this alone, change only above two
|
||||
|
||||
// Set the static IP address to use if the DHCP fails to assign
|
||||
IPAddress ip(192, 168, 0, 177);
|
||||
IPAddress myDns(8, 8, 8, 8);
|
||||
|
||||
// Choose the analog pin to get semi-random data from for SSL
|
||||
// Pick a pin that's not connected or attached to a randomish voltage source
|
||||
const int rand_pin = A7;
|
||||
|
||||
// Initialize the SSL client library
|
||||
// We input an EthernetClient, our trust anchors, and the analog pin
|
||||
SSLClient<EthernetClient> client(EthernetClient(), TAs, (size_t)TAs_NUM, rand_pin);
|
||||
// Variables to measure the speed
|
||||
unsigned long beginMicros, endMicros;
|
||||
unsigned long byteCount = 0;
|
||||
bool printWebData = true; // set to false for better speed measurement
|
||||
|
||||
void setup() {
|
||||
// You can use Ethernet.init(pin) to configure the CS pin
|
||||
Ethernet.init(10); // Most Arduino shields
|
||||
//Ethernet.init(5); // MKR ETH shield
|
||||
//Ethernet.init(0); // Teensy 2.0
|
||||
//Ethernet.init(20); // Teensy++ 2.0
|
||||
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
|
||||
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
|
||||
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
// start the Ethernet connection:
|
||||
Serial.println("Initialize Ethernet with DHCP:");
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
Serial.println("Failed to configure Ethernet using DHCP");
|
||||
// Check for Ethernet hardware present
|
||||
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
|
||||
while (true) {
|
||||
delay(1); // do nothing, no point running without Ethernet hardware
|
||||
}
|
||||
}
|
||||
if (Ethernet.linkStatus() == LinkOFF) {
|
||||
Serial.println("Ethernet cable is not connected.");
|
||||
}
|
||||
// try to configure using IP address instead of DHCP:
|
||||
Ethernet.begin(mac, ip, myDns);
|
||||
} else {
|
||||
Serial.print(" DHCP assigned IP ");
|
||||
Serial.println(Ethernet.localIP());
|
||||
}
|
||||
// give the Ethernet shield a second to initialize:
|
||||
delay(2000);
|
||||
|
||||
Serial.print("connecting to ");
|
||||
Serial.print(server);
|
||||
Serial.println("...");
|
||||
|
||||
// if you get a connection, report back via serial:
|
||||
auto start = millis();
|
||||
// specify the server and port, 443 is the standard port for HTTPS
|
||||
if (client.connect(server, 443)) {
|
||||
auto time = millis() - start;
|
||||
Serial.print("connected to ");
|
||||
Serial.println(client.remoteIP());
|
||||
Serial.print("Took: ");
|
||||
Serial.println(time);
|
||||
// Make a HTTP request:
|
||||
client.println("GET /asciilogo.txt HTTP/1.1");
|
||||
client.println("User-Agent: SSLClientOverEthernet");
|
||||
client.print("Host: ");
|
||||
client.println(server_host);
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
} else {
|
||||
// if you didn't get a connection to the server:
|
||||
Serial.println("connection failed");
|
||||
}
|
||||
beginMicros = micros();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if there are incoming bytes available
|
||||
// from the server, read them and print them:
|
||||
int len = client.available();
|
||||
if (len > 0) {
|
||||
byte buffer[80];
|
||||
if (len > 80) len = 80;
|
||||
client.read(buffer, len);
|
||||
if (printWebData) {
|
||||
Serial.write(buffer, len); // show in the serial monitor (slows some boards)
|
||||
}
|
||||
byteCount = byteCount + len;
|
||||
}
|
||||
|
||||
// if the server's disconnected, stop the client:
|
||||
if (!client.connected()) {
|
||||
endMicros = micros();
|
||||
Serial.println();
|
||||
Serial.println("disconnecting.");
|
||||
client.stop();
|
||||
Serial.print("Received ");
|
||||
Serial.print(byteCount);
|
||||
Serial.print(" bytes in ");
|
||||
float seconds = (float)(endMicros - beginMicros) / 1000000.0;
|
||||
Serial.print(seconds, 4);
|
||||
float rate = (float)byteCount / seconds / 1000.0;
|
||||
Serial.print(", rate = ");
|
||||
Serial.print(rate);
|
||||
Serial.print(" kbytes/second");
|
||||
Serial.println();
|
||||
|
||||
// do nothing forevermore:
|
||||
while (true) {
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
}
|
79
examples/EthernetHTTPS/trust_anchors.h
Normal file
79
examples/EthernetHTTPS/trust_anchors.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
#ifndef _CERTIFICATES_H_
|
||||
#define _CERTIFICATES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* This file is auto-generated by the pycert_bearssl tool. Do not change it manually.
|
||||
* Certificates are BearSSL br_x509_trust_anchor format. Included certs:
|
||||
*
|
||||
* Index: 0
|
||||
* Label: Starfield Class 2 Certification Authority
|
||||
* Subject: C=US,O=Starfield Technologies\, Inc.,OU=Starfield Class 2 Certification Authority
|
||||
* Domain(s): www.arduino.cc
|
||||
*/
|
||||
|
||||
#define TAs_NUM 1
|
||||
|
||||
static const unsigned char TA_DN0[] = {
|
||||
0x30, 0x68, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
|
||||
0x02, 0x55, 0x53, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x0a,
|
||||
0x13, 0x1c, 0x53, 0x74, 0x61, 0x72, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x20,
|
||||
0x54, 0x65, 0x63, 0x68, 0x6e, 0x6f, 0x6c, 0x6f, 0x67, 0x69, 0x65, 0x73,
|
||||
0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x32, 0x30, 0x30, 0x06, 0x03,
|
||||
0x55, 0x04, 0x0b, 0x13, 0x29, 0x53, 0x74, 0x61, 0x72, 0x66, 0x69, 0x65,
|
||||
0x6c, 0x64, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x32, 0x20, 0x43,
|
||||
0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79,
|
||||
};
|
||||
|
||||
static const unsigned char TA_RSA_N0[] = {
|
||||
0xb7, 0x32, 0xc8, 0xfe, 0xe9, 0x71, 0xa6, 0x04, 0x85, 0xad, 0x0c, 0x11,
|
||||
0x64, 0xdf, 0xce, 0x4d, 0xef, 0xc8, 0x03, 0x18, 0x87, 0x3f, 0xa1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 0x35, 0xb3, 0xbc, 0x69, 0xca, 0xf5, 0xcc, 0x9d, 0xe8, 0xfd, 0x64,
|
||||
0x8d, 0x17, 0x80, 0x33, 0x6e, 0x5e, 0x4a, 0x5d, 0x99, 0xc9, 0x1e, 0x87,
|
||||
0xb4, 0x9d, 0x1a, 0xc0, 0xd5, 0x6e, 0x13, 0x35, 0x23, 0x5e, 0xdf, 0x9b,
|
||||
0x5f, 0x3d, 0xef, 0xd6, 0xf7, 0x76, 0xc2, 0xea, 0x3e, 0xbb, 0x78, 0x0d,
|
||||
0x1c, 0x42, 0x67, 0x6b, 0x04, 0xd8, 0xf8, 0xd6, 0xda, 0x6f, 0x8b, 0xf2,
|
||||
0x44, 0xa0, 0x01, 0xab,
|
||||
};
|
||||
|
||||
static const unsigned char TA_RSA_E0[] = {
|
||||
0x03,
|
||||
};
|
||||
|
||||
static const br_x509_trust_anchor TAs[] = {
|
||||
{
|
||||
{ (unsigned char *)TA_DN0, sizeof TA_DN0 },
|
||||
BR_X509_TA_CA,
|
||||
{
|
||||
BR_KEYTYPE_RSA,
|
||||
{ .rsa = {
|
||||
(unsigned char *)TA_RSA_N0, sizeof TA_RSA_N0,
|
||||
(unsigned char *)TA_RSA_E0, sizeof TA_RSA_E0,
|
||||
} }
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* ifndef _CERTIFICATES_H_ */
|
167
examples/EthernetMultiHTTPS/EthernetMultiHTTPS.ino
Normal file
167
examples/EthernetMultiHTTPS/EthernetMultiHTTPS.ino
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
Multi Domain HTTPS Client
|
||||
|
||||
This sketch connects to a website (http://www.arduino.cc/asciilogo.txt)
|
||||
using an Arduino Wiznet Ethernet shield.
|
||||
|
||||
Circuit:
|
||||
* Ethernet shield attached to pins 10, 11, 12, 13
|
||||
|
||||
created 18 Dec 2009
|
||||
by David A. Mellis
|
||||
modified 9 Apr 2012
|
||||
by Noah Koontz, based on work by Adrian McEwen and Tom Igoe
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// NOTE: The Ethernet library MUST be modified to use this example!
|
||||
// For more detailed instructions check out https://github.com/OPEnSLab-OSU/SSLClient#sslclient-with-ethernet
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SSLClient.h>
|
||||
#include "trustanchors.h"
|
||||
// Enter a MAC address for your controller below.
|
||||
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
|
||||
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
|
||||
|
||||
// the two domains we want to query
|
||||
char server1[] = "www.arduino.cc";
|
||||
char server2[] = "www.cloudflare.com";
|
||||
// and the queries we want to send to them
|
||||
char query1[] = "GET /asciilogo.txt HTTP/1.1";
|
||||
char query2[] = "GET /cdn-cgi/trace HTTP/1.1";
|
||||
|
||||
// Set the static IP address to use if the DHCP fails to assign
|
||||
IPAddress ip(192, 168, 0, 177);
|
||||
IPAddress myDns(8, 8, 8, 8);
|
||||
|
||||
// Choose the analog pin to get semi-random data from for SSL
|
||||
// Pick a pin that's not connected or attached to a randomish voltage source
|
||||
const int rand_pin = A7;
|
||||
|
||||
// Initialize the SSL client library
|
||||
// We input an EthernetClient, our trust anchors, and the analog pin
|
||||
// Additionally specify that we want to store 2 sessions since we are connecting to 2 domains
|
||||
SSLClient<EthernetClient, 2> client(EthernetClient(), TAs, (size_t)TAs_NUM, rand_pin);
|
||||
// Variables to measure the speed
|
||||
unsigned long beginMicros, endMicros;
|
||||
unsigned long byteCount = 0;
|
||||
bool printWebData = true; // set to false for better speed measurement
|
||||
|
||||
void setup() {
|
||||
// You can use Ethernet.init(pin) to configure the CS pin
|
||||
Ethernet.init(10); // Most Arduino shields
|
||||
//Ethernet.init(5); // MKR ETH shield
|
||||
//Ethernet.init(0); // Teensy 2.0
|
||||
//Ethernet.init(20); // Teensy++ 2.0
|
||||
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
|
||||
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
|
||||
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
// start the Ethernet connection:
|
||||
Serial.println("Initialize Ethernet with DHCP:");
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
Serial.println("Failed to configure Ethernet using DHCP");
|
||||
// Check for Ethernet hardware present
|
||||
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
|
||||
while (true) {
|
||||
delay(1); // do nothing, no point running without Ethernet hardware
|
||||
}
|
||||
}
|
||||
if (Ethernet.linkStatus() == LinkOFF) {
|
||||
Serial.println("Ethernet cable is not connected.");
|
||||
}
|
||||
// try to congifure using IP address instead of DHCP:
|
||||
Ethernet.begin(mac, ip, myDns);
|
||||
} else {
|
||||
Serial.print(" DHCP assigned IP ");
|
||||
Serial.println(Ethernet.localIP());
|
||||
}
|
||||
// give the Ethernet shield a second to initialize:
|
||||
delay(2000);
|
||||
// connect!
|
||||
connectSSL();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if there are incoming bytes available
|
||||
// from the server, read them and print them:
|
||||
int len = client.available();
|
||||
if (len > 0) {
|
||||
byte buffer[80];
|
||||
if (len > 80) len = 80;
|
||||
client.read(buffer, len);
|
||||
if (printWebData) {
|
||||
Serial.write(buffer, len); // show in the serial monitor (slows some boards)
|
||||
}
|
||||
byteCount = byteCount + len;
|
||||
}
|
||||
|
||||
// if the server's disconnected, stop the client:
|
||||
if (!client.connected()) {
|
||||
endMicros = micros();
|
||||
Serial.println();
|
||||
Serial.println("disconnecting.");
|
||||
client.stop();
|
||||
Serial.print("Received ");
|
||||
Serial.print(byteCount);
|
||||
Serial.print(" bytes in ");
|
||||
float seconds = (float)(endMicros - beginMicros) / 1000000.0;
|
||||
Serial.print(seconds, 4);
|
||||
float rate = (float)byteCount / seconds / 1000.0;
|
||||
Serial.print(", rate = ");
|
||||
Serial.print(rate);
|
||||
Serial.print(" kbytes/second");
|
||||
Serial.println();
|
||||
|
||||
//quick delay
|
||||
delay(1000);
|
||||
// connect again!
|
||||
connectSSL();
|
||||
}
|
||||
}
|
||||
|
||||
bool r = false;
|
||||
|
||||
void connectSSL() {
|
||||
// cycle the server we want to connect to back and forth
|
||||
char* server;
|
||||
if (r) server = server1;
|
||||
else server = server2;
|
||||
r = !r;
|
||||
|
||||
Serial.print("connecting to ");
|
||||
Serial.print(server);
|
||||
Serial.println("...");
|
||||
|
||||
// if you get a connection, report back via serial:
|
||||
auto start = millis();
|
||||
if (client.connect(server, 443)) {
|
||||
auto time = millis() - start;
|
||||
Serial.print("connected to ");
|
||||
Serial.println(client.remoteIP());
|
||||
Serial.print("Took: ");
|
||||
Serial.println(time);
|
||||
// Make a HTTP request:
|
||||
if (server == server1) client.println(query1);
|
||||
else client.println(query2);
|
||||
client.println("User-Agent: SSLClientOverEthernet");
|
||||
client.print("Host: ");
|
||||
client.println(server);
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
client.flush();
|
||||
} else {
|
||||
// if you didn't get a connection to the server:
|
||||
Serial.println("connection failed");
|
||||
}
|
||||
beginMicros = micros();
|
||||
}
|
137
examples/EthernetMultiHTTPS/trustanchors.h
Normal file
137
examples/EthernetMultiHTTPS/trustanchors.h
Normal file
|
@ -0,0 +1,137 @@
|
|||
#ifndef _CERTIFICATES_H_
|
||||
#define _CERTIFICATES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* This file is auto-generated by the pycert_bearssl tool. Do not change it manually.
|
||||
* Certificates are BearSSL br_x509_trust_anchor format. Included certs:
|
||||
*
|
||||
* Index: 0
|
||||
* Label: Starfield Class 2 Certification Authority
|
||||
* Subject: C=US,O=Starfield Technologies\, Inc.,OU=Starfield Class 2 Certification Authority
|
||||
* Domain(s): www.arduino.cc
|
||||
*
|
||||
* Index: 1
|
||||
* Label: DigiCert High Assurance EV Root CA
|
||||
* Subject: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert High Assurance EV Root CA
|
||||
* Domain(s): www.cloudflare.com
|
||||
*/
|
||||
|
||||
#define TAs_NUM 2
|
||||
|
||||
static const unsigned char TA_DN0[] = {
|
||||
0x30, 0x68, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
|
||||
0x02, 0x55, 0x53, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x0a,
|
||||
0x13, 0x1c, 0x53, 0x74, 0x61, 0x72, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x20,
|
||||
0x54, 0x65, 0x63, 0x68, 0x6e, 0x6f, 0x6c, 0x6f, 0x67, 0x69, 0x65, 0x73,
|
||||
0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x32, 0x30, 0x30, 0x06, 0x03,
|
||||
0x55, 0x04, 0x0b, 0x13, 0x29, 0x53, 0x74, 0x61, 0x72, 0x66, 0x69, 0x65,
|
||||
0x6c, 0x64, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x32, 0x20, 0x43,
|
||||
0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79,
|
||||
};
|
||||
|
||||
static const unsigned char TA_RSA_N0[] = {
|
||||
0xb7, 0x32, 0xc8, 0xfe, 0xe9, 0x71, 0xa6, 0x04, 0x85, 0xad, 0x0c, 0x11,
|
||||
0x64, 0xdf, 0xce, 0x4d, 0xef, 0xc8, 0x03, 0x18, 0x87, 0x3f, 0xa1, 0xab,
|
||||
0xfb, 0x3c, 0xa6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0xf5, 0xcc, 0x9d, 0xe8, 0xfd, 0x64,
|
||||
0x8d, 0x17, 0x80, 0x33, 0x6e, 0x5e, 0x4a, 0x5d, 0x99, 0xc9, 0x1e, 0x87,
|
||||
0xb4, 0x9d, 0x1a, 0xc0, 0xd5, 0x6e, 0x13, 0x35, 0x23, 0x5e, 0xdf, 0x9b,
|
||||
0x5f, 0x3d, 0xef, 0xd6, 0xf7, 0x76, 0xc2, 0xea, 0x3e, 0xbb, 0x78, 0x0d,
|
||||
0x1c, 0x42, 0x67, 0x6b, 0x04, 0xd8, 0xf8, 0xd6, 0xda, 0x6f, 0x8b, 0xf2,
|
||||
0x44, 0xa0, 0x01, 0xab,
|
||||
};
|
||||
|
||||
static const unsigned char TA_RSA_E0[] = {
|
||||
0x03,
|
||||
};
|
||||
|
||||
static const unsigned char TA_DN1[] = {
|
||||
0x30, 0x6c, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
|
||||
0x02, 0x55, 0x53, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a,
|
||||
0x13, 0x0c, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x49,
|
||||
0x6e, 0x63, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13,
|
||||
0x10, 0x77, 0x77, 0x77, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72,
|
||||
0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x31, 0x2b, 0x30, 0x29, 0x06, 0x03, 0x55,
|
||||
0x04, 0x03, 0x13, 0x22, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74,
|
||||
0x20, 0x48, 0x69, 0x67, 0x68, 0x20, 0x41, 0x73, 0x73, 0x75, 0x72, 0x61,
|
||||
0x6e, 0x63, 0x65, 0x20, 0x45, 0x56, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20,
|
||||
0x43, 0x41,
|
||||
};
|
||||
|
||||
static const unsigned char TA_RSA_N1[] = {
|
||||
0xc6, 0xcc, 0xe5, 0x73, 0xe6, 0xfb, 0xd4, 0xbb, 0xe5, 0x2d, 0x2d, 0x32,
|
||||
0xa6, 0xdf, 0xe5, 0x81, 0x3f, 0xc9, 0xcd, 0x25, 0x49, 0xb6, 0x71, 0x2a,
|
||||
0xc3, 0xd5, 0x94, 0x34, 0x67, 0xa2, 0x0a, 0x1c, 0xb0, 0x5f, 0x69, 0xa6,
|
||||
0x40, 0xb1, 0xc4, 0xb7, 0xb2, 0x8f, 0xd0, 0x98, 0xa4, 0xa9, 0x41, 0x59,
|
||||
0x3a, 0xd3, 0xdc, 0x94, 0xd6, 0x3c, 0xdb, 0x74, 0x38, 0xa4, 0x4a, 0xcc,
|
||||
0x4d, 0x25, 0x82, 0xf7, 0x4a, 0xa5, 0x53, 0x12, 0x38, 0xee, 0xf3, 0x49,
|
||||
0x6d, 0x71, 0x91, 0x7e, 0x63, 0xb6, 0xab, 0xa6, 0x5f, 0xc3, 0xa4, 0x84,
|
||||
0xf8, 0x4f, 0x62, 0x51, 0xbe, 0xf8, 0xc5, 0xec, 0xdb, 0x38, 0x92, 0xe3,
|
||||
0x06, 0xe5, 0x08, 0x91, 0x0c, 0xc4, 0x28, 0x41, 0x55, 0xfb, 0xcb, 0x5a,
|
||||
0x89, 0x15, 0x7e, 0x71, 0xe8, 0x35, 0xbf, 0x4d, 0x72, 0x09, 0x3d, 0xbe,
|
||||
0x3a, 0x38, 0x50, 0x5b, 0x77, 0x31, 0x1b, 0x8d, 0xb3, 0xc7, 0x24, 0x45,
|
||||
0x9a, 0xa7, 0xac, 0x6d, 0x00, 0x14, 0x5a, 0x04, 0xb7, 0xba, 0x13, 0xeb,
|
||||
0x51, 0x0a, 0x98, 0x41, 0x41, 0x22, 0x4e, 0x65, 0x61, 0x87, 0x81, 0x41,
|
||||
0x50, 0xa6, 0x79, 0x5c, 0x89, 0xde, 0x19, 0x4a, 0x57, 0xd5, 0x2e, 0xe6,
|
||||
0x5d, 0x1c, 0x53, 0x2c, 0x7e, 0x98, 0xcd, 0x1a, 0x06, 0x16, 0xa4, 0x68,
|
||||
0x73, 0xd0, 0x34, 0x04, 0x13, 0x5c, 0xa1, 0x71, 0xd3, 0x5a, 0x7c, 0x55,
|
||||
0xdb, 0x5e, 0x64, 0xe1, 0x37, 0x87, 0x30, 0x56, 0x04, 0xe5, 0x11, 0xb4,
|
||||
0x29, 0x80, 0x12, 0xf1, 0x79, 0x39, 0x88, 0xa2, 0x02, 0x11, 0x7c, 0x27,
|
||||
0x66, 0xb7, 0x88, 0xb7, 0x78, 0xf2, 0xca, 0x0a, 0xa8, 0x38, 0xab, 0x0a,
|
||||
0x64, 0xc2, 0xbf, 0x66, 0x5d, 0x95, 0x84, 0xc1, 0xa1, 0x25, 0x1e, 0x87,
|
||||
0x5d, 0x1a, 0x50, 0x0b, 0x20, 0x12, 0xcc, 0x41, 0xbb, 0x6e, 0x0b, 0x51,
|
||||
0x38, 0xb8, 0x4b, 0xcb,
|
||||
};
|
||||
|
||||
static const unsigned char TA_RSA_E1[] = {
|
||||
0x01, 0x00, 0x01,
|
||||
};
|
||||
|
||||
static const br_x509_trust_anchor TAs[] = {
|
||||
{
|
||||
{ (unsigned char *)TA_DN0, sizeof TA_DN0 },
|
||||
BR_X509_TA_CA,
|
||||
{
|
||||
BR_KEYTYPE_RSA,
|
||||
{ .rsa = {
|
||||
(unsigned char *)TA_RSA_N0, sizeof TA_RSA_N0,
|
||||
(unsigned char *)TA_RSA_E0, sizeof TA_RSA_E0,
|
||||
} }
|
||||
}
|
||||
},
|
||||
{
|
||||
{ (unsigned char *)TA_DN1, sizeof TA_DN1 },
|
||||
BR_X509_TA_CA,
|
||||
{
|
||||
BR_KEYTYPE_RSA,
|
||||
{ .rsa = {
|
||||
(unsigned char *)TA_RSA_N1, sizeof TA_RSA_N1,
|
||||
(unsigned char *)TA_RSA_E1, sizeof TA_RSA_E1,
|
||||
} }
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* ifndef _CERTIFICATES_H_ */
|
|
@ -343,7 +343,7 @@ int SSLClientImpl::m_start_ssl(const char* host, SSLSession& ssl_ses) {
|
|||
setWriteError(SSL_BR_CONNECT_FAIL);
|
||||
return 0;
|
||||
}
|
||||
// initlalize the SSL socket over the network
|
||||
// initialize the SSL socket over the network
|
||||
// normally this would happen in write, but I think it makes
|
||||
// a little more structural sense to put it here
|
||||
if (m_run_until(BR_SSL_SENDAPP) < 0) {
|
||||
|
|
Loading…
Reference in a new issue