]> git.sesse.net Git - vlc/blob - contrib/src/gnutls/mac-keychain-lookup.patch
contribs: bluray: Fix xml2 option name
[vlc] / contrib / src / gnutls / mac-keychain-lookup.patch
1 diff -ru gnutls-old/lib/Makefile.am gnutls/lib/Makefile.am
2 --- gnutls-old/lib/Makefile.am  2013-06-02 19:33:57.000000000 +0200
3 +++ gnutls/lib/Makefile.am      2013-11-10 13:28:18.000000000 +0100
4 @@ -152,6 +152,10 @@
5  DISTCLEANFILES += $(defexec_DATA)
6  endif
7  
8 +if MACOSX
9 +libgnutls_la_LDFLAGS +=  -Wl,-framework,Security,-framework,CoreFoundation
10 +endif
11 +
12  if WINDOWS
13  thirdparty_libadd += -lcrypt32
14  endif
15 diff -ru gnutls-old/lib/system.c gnutls/lib/system.c
16 --- gnutls-old/lib/system.c     2013-04-10 22:25:51.000000000 +0200
17 +++ gnutls/lib/system.c 2013-11-10 13:30:31.000000000 +0100
18 @@ -57,6 +57,15 @@
19  #undef send
20  #undef select
21  
22 +#ifdef __APPLE__
23 +#include "TargetConditionals.h"
24 +#ifdef TARGET_OS_MAC
25 +#define _UINT64
26 +#include <Security/Security.h>
27 +#include <Security/SecCertificate.h>
28 +#endif
29 +#endif
30 +
31  /* System specific function wrappers.
32   */
33  
34 @@ -550,6 +559,40 @@
35  
36    return r;
37  }
38 +#elif defined(__APPLE__)
39 +#if TARGET_OS_MAC
40 +static
41 +int add_system_trust(gnutls_x509_trust_list_t list, unsigned int tl_flags, unsigned int tl_vflags)
42 +{
43 +    CFArrayRef anchors;
44 +    int ret = 0;
45 +    if (SecTrustCopyAnchorCertificates(&anchors) != 0)
46 +        return -1;
47 +
48 +    CFIndex count = CFArrayGetCount(anchors);
49 +    for (int i = 0; i < count; i++) {
50 +        SecCertificateRef certref = (SecCertificateRef)CFArrayGetValueAtIndex(anchors, i);
51 +
52 +        CSSM_DATA certData;
53 +        SecCertificateGetData(certref, &certData);
54 +        gnutls_datum data = {
55 +            .data = certData.Data,
56 +            .size = certData.Length,
57 +        };
58 +
59 +        if (!gnutls_x509_trust_list_add_trust_mem(list, &data, NULL, GNUTLS_X509_FMT_DER, tl_flags, tl_vflags))
60 +            printf("cannot add x509 credentials\n");
61 +        else
62 +            ret++;
63 +    }
64 +    CFRelease(anchors);
65 +
66 +    return ret;
67 +}
68 +
69 +#else
70 +#define add_system_trust(x,y,z) GNUTLS_E_UNIMPLEMENTED_FEATURE
71 +#endif
72  #else
73  
74  #define add_system_trust(x,y,z) GNUTLS_E_UNIMPLEMENTED_FEATURE