I'm use host to request https://MyHost/ the networkProtocolName return "h3"
assumesHTTP3Capable = YES
- (void)URLSession:(NSURLSession *)session
task:(NSURLSessionTask *)task
didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10))
{
for (NSURLSessionTaskTransactionMetrics * m in metrics.transactionMetrics){
if(m.networkProtocolName.length > 0){
NSLog(@"networkProtocolName %@", m.networkProtocolName);
break;
}
}
}
but when I use ip replace MyHost to request, and add MyHost to http header @{@"host": "ip"}, the networkProtocolName return "h2"
- (void)URLSession:(NSURLSession *)session
task:(NSURLSessionTask *)task
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
NSURLCredential *credential = nil;
//get header host replace ip
NSString *host = [[task.currentRequest allHTTPHeaderFields] objectForKey:@"host"];
if (!host) {
host = task.currentRequest.URL.host;
}
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
if ([weak evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:host]) {
disposition = NSURLSessionAuthChallengeUseCredential;
credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
} else {
disposition = NSURLSessionAuthChallengePerformDefaultHandling;
}
} else {
disposition = NSURLSessionAuthChallengePerformDefaultHandling;
}
// 对于其他的 challenges 直接使用默认的验证方案
completionHandler(disposition,credential);
}
-(BOOL)evaluateServerTrust:(SecTrustRef)serverTrust forDomain:(NSString *)domain {
//创建证书校验策略
NSMutableArray *policies = [NSMutableArray array];
if (domain) {
[policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)];
} else {
[policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()];
}
//绑定校验策略到服务端的证书上
SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies);
//评估当前 serverTrust 是否可信任,
//官方建议在 result = kSecTrustResultUnspecified 或 kSecTrustResultProceed 的情况下 serverTrust 可以被验证通过,
//https://developer.apple.com/library/ios/technotes/tn2232/_index.html
//关于SecTrustResultType的详细信息请参考SecTrust.h
SecTrustResultType result;
SecTrustEvaluate(serverTrust, &result);
return (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed);
}
https://ip/ networkProtocolName return "h2"
does ip request do not supprt HTTP/3?
hope to respone thank you.
Post
Replies
Boosts
Views
Activity
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x0000001000000008
Exception Codes: 0x0000000000000002, 0x0000001000000008
VM Region Info: 0x1000000008 is in 0x1000000000-0x7000000000; bytes after start: 8 bytes before end: 412316860407
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
commpage (reserved) fffffc000-1000000000 [ 16K] ---/--- SM=NUL ...(unallocated)
---> GPU Carveout (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated)
UNUSED SPACE AT END
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 10 Bus error: 10
Terminating Process: exc handler [87825]
Triggered by Thread: 0
Kernel Triage:
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
Thread 0 name:
Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001983f8cf4 objc_msgSend + 20 (:-1)
1 UIKitCore 0x00000001832d34d4 -[UIInputWindowController updateSupportsDockViewController] + 168 (UIInputWindowController.m:1224)
2 UIKitCore 0x00000001833561fc -[UIInputWindowController _updateContentOverlayInsetsForSelfAndChildren] + 64 (UIInputWindowController.m:1242)
crash in random, and have no Valid info.
2022-10-25_10-03-30.8604_-0400-8f6072ef9d771635aaa9900c79aa2406b00a6123.crash
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001df4c6f24 __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x0000000218bec298 _pthread_cond_wait + 1236 (pthread_cond.c:636)
2 JavaScriptCore 0x00000001b2c3cc20 ***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) + 1844 (ThreadingPOSIX.cpp:622)
3 WebKit 0x00000001b682a220 bool ***::Condition::waitUntilUncheckedWTF::Lock(***::Lock&, ***::TimeWithDynamicClockType const&) + 196 (ParkingLot.h:82)
4 WebKit 0x00000001b69fe8e0 IPC::Connection::waitForMessage(IPC::MessageName, unsigned long long, IPC::Timeout, ***::OptionSetIPC::WaitForOption) + 520 (Condition.h:77)
5 WebKit 0x00000001b6ad0144 WebKit::RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateActivityState(unsigned long long) + 172 (Connection.h:633)
6 WebKit 0x00000001b6c3074c WebKit::WebPageProxy::dispatchActivityStateChange() + 2108 (WebPageProxy.cpp:2379)
2022-10-22_17-57-38.5588_+0800-5e45050864bf1d610e0f1451bbb7e5349c14e03c.crash