GNUTLS中的SNI,何时询问
SNI in GNUTLS, when to ask?
所以,我试图在我的GNUTLS服务器中实现SNI。
我的代码:if(sniCallback != NULL) {
size_t ds = 256;
char data[ds];
unsigned int type = (unsigned int)GNUTLS_NAME_DNS;
int snir = gnutls_server_name_get(sessiond, &data[0], &ds, &type, (unsigned int)0);
data[ds - 1] = 0; // the last one must always be
if(snir >= 0) {
jstring js = (*this)->NewStringUTF(this, data);
jlong snicert = (*this)->CallLongMethod(this, sniCallback, (*this)->GetMethodID(this, (*this)->GetObjectClass(this, sniCallback), "getSNICert", "(Ljava/lang/String;)J"), js);
if(snicert > 0L) {
struct cert* oc = (struct cert*)snicert;
gnutls_credentials_set(sessiond, GNUTLS_CRD_CERTIFICATE, oc->cert);
}
} else {
printf("%in", snir);
}
}
(不介意JNI)
我得到-56错误代码,这是GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
,文档翻译为未发送SNI(尚未)。我如何知道我何时有SNI信息?也就是我什么时候能得到客户端你好?我直接从Chrome得到这个,所以我知道有SNI。这些都是NIO的
对于那些和我在同一条道路上的人,答案是:
gnutls_handshake_set_post_client_hello_function
相关文章:
- 何时在引用或唯一指针上使用移动语义
- 何时提供默认参数作为模板参数
- C++-明确何时以及如何调用析构函数
- 在以唯一ptr为值的C++映射中,动态内存何时会被销毁
- 何时应通过引用传递矢量参数而不是按值传递矢量参数?
- 如果非动态变量被指针引用,何时超出范围?
- 类作用域的类型别名"using":[何时]方法中的用法可以先于类型别名?
- 何时定义QT_NO_CONTEXTMENU?
- 如何通过多类"Union variable" (sfml) 使用轮询事件
- 何时为派生类初始化 vptr?
- 如何知道何时调用删除以及何时调用 delete[] C++?
- 指针的 C++ 动态数组 - 何时需要使用它?
- 我应该在 C++ 中何时/为什么使用 STATIC?
- 变量的值何时可以在C++中意外更改?
- 不带轮询的 SDL2 事件回调
- 调用方如何知道 VARIANT 中何时有十进制?
- 何时应在构造函数参数中使用 const C++?
- 我可以有一个 ELI5 作为参考和指针以及何时使用它们吗?
- 如何实现std ::何时_any而不进行轮询
- GNUTLS中的SNI,何时询问