josip04
josip04

Reputation: 234

Difference between kCFStreamSSLLevel and kCFStreamPropertySocketSecurityLevel

Can someone please explain difference between these 2 properties? They accept same set of values defined in https://developer.apple.com/documentation/corefoundation/cfstream/cfstream_socket_security_level_constants

kCFStreamSSLLevel is set in kCFStreamPropertySSLSettings dictionary and kCFStreamPropertySocketSecurityLevel directly.

Documentation doesn't say much about any of them.

Upvotes: 2

Views: 238

Answers (1)

Mecki
Mecki

Reputation: 132869

Looking at the source code, setting the property kCFStreamPropertySocketSecurityLevel internally just creates a dictionary where the property value is stored for the key kCFStreamSSLLevel and the created dictionary is passed to a function that is also called when the property kCFStreamPropertySSLSettings is set.

So this code:

CFReadStreamSetProperty(
    stream, 
    kCFStreamPropertySocketSecurityLevel,  
    kCFStreamSocketSecurityLevelNegotiatedSSL);

is equivalent to this code

CFMutableDictionaryRef settings =   
    CFDictionaryCreateMutable(
        NULL, 0,
        &kCFTypeDictionaryKeyCallBacks,
        &kCFTypeDictionaryValueCallBacks);

CFDictionaryAddValue(
    settings, 
    kCFStreamSSLLevel,
    kCFStreamSocketSecurityLevelNegotiatedSSL);

CFReadStreamSetProperty(
    stream, 
    kCFStreamPropertySSLSettings,  
    settings);

Upvotes: 0

Related Questions