| 191 | } |
| 192 | |
| 193 | std::string find_CN(const std::string &subject) { |
| 194 | // The subject string is returned with different whitespace and component ordering between platforms. |
| 195 | // Here we just return the common name by searching for "CN=...." in the subject, knowing that |
| 196 | // the test certificates do not contain any escaped characters. |
| 197 | size_t pos = subject.find("CN="); |
| 198 | if (pos == std::string::npos) throw std::runtime_error("No common name in certificate subject"); |
| 199 | std::string cn = subject.substr(pos); |
| 200 | pos = cn.find(','); |
| 201 | return pos == std::string::npos ? cn : cn.substr(0, pos); |
| 202 | } |
no test coverage detected