| 183 | } |
| 184 | |
| 185 | std::string hex_encode(unsigned char* data, size_t len) |
| 186 | { |
| 187 | std::stringstream ss; |
| 188 | ss << std::hex << std::setfill('0'); |
| 189 | for (size_t i = 0; i < len; i++) |
| 190 | { |
| 191 | // Cast data[i] to an int so that it uses the int-based overload of the << operator. |
| 192 | // If it uses the char-based overload then it's going to treat data[i] as a printable character. |
| 193 | // See: [https://arstechnica.com/civis/viewtopic.php?t=796634](https://arstechnica.com/civis/viewtopic.php?t=796634) |
| 194 | ss << std::setw(2) << static_cast<unsigned int>(data[i]); |
| 195 | } |
| 196 | return ss.str(); |
| 197 | } |
| 198 | |
| 199 | void getTestCert() |
| 200 | { |