grpc 0.13.1 → 0.14.1.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +2098 -828
- data/include/grpc/byte_buffer.h +1 -1
- data/include/grpc/byte_buffer_reader.h +1 -20
- data/include/grpc/census.h +4 -4
- data/include/grpc/compression.h +6 -5
- data/include/grpc/grpc.h +31 -20
- data/include/grpc/grpc_security.h +17 -31
- data/include/grpc/grpc_security_constants.h +114 -0
- data/include/grpc/grpc_zookeeper.h +1 -1
- data/include/grpc/impl/codegen/alloc.h +1 -1
- data/include/grpc/impl/codegen/atm.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_sync.h +1 -1
- data/include/grpc/impl/codegen/atm_win32.h +1 -1
- data/include/grpc/impl/codegen/byte_buffer.h +1 -1
- data/{src/core/client_config/lb_policies/round_robin.h → include/grpc/impl/codegen/byte_buffer_reader.h} +19 -8
- data/include/grpc/impl/codegen/grpc_types.h +20 -3
- data/include/grpc/impl/codegen/log.h +9 -2
- data/include/grpc/impl/codegen/port_platform.h +102 -17
- data/include/grpc/impl/codegen/propagation_bits.h +3 -3
- data/include/grpc/impl/codegen/slice.h +3 -3
- data/include/grpc/impl/codegen/slice_buffer.h +3 -3
- data/include/grpc/impl/codegen/status.h +1 -1
- data/include/grpc/impl/codegen/sync_generic.h +1 -1
- data/include/grpc/impl/codegen/sync_posix.h +1 -1
- data/include/grpc/impl/codegen/sync_win32.h +1 -1
- data/include/grpc/impl/codegen/time.h +3 -3
- data/include/grpc/status.h +1 -1
- data/include/grpc/support/alloc.h +1 -1
- data/include/grpc/support/atm.h +1 -1
- data/include/grpc/support/atm_gcc_atomic.h +4 -4
- data/include/grpc/support/atm_gcc_sync.h +1 -1
- data/include/grpc/support/atm_win32.h +1 -1
- data/include/grpc/support/avl.h +1 -1
- data/include/grpc/support/cmdline.h +1 -1
- data/include/grpc/support/cpu.h +1 -1
- data/include/grpc/support/histogram.h +1 -1
- data/include/grpc/support/host_port.h +1 -1
- data/include/grpc/support/log.h +1 -1
- data/include/grpc/support/log_win32.h +1 -1
- data/include/grpc/support/port_platform.h +1 -1
- data/include/grpc/support/slice.h +1 -1
- data/include/grpc/support/slice_buffer.h +1 -1
- data/include/grpc/support/string_util.h +3 -1
- data/include/grpc/support/subprocess.h +2 -2
- data/include/grpc/support/sync.h +1 -1
- data/include/grpc/support/sync_generic.h +1 -1
- data/include/grpc/support/sync_posix.h +1 -1
- data/include/grpc/support/sync_win32.h +1 -1
- data/include/grpc/support/thd.h +1 -1
- data/include/grpc/support/time.h +1 -1
- data/include/grpc/support/tls.h +1 -1
- data/include/grpc/support/tls_gcc.h +45 -1
- data/include/grpc/support/tls_msvc.h +3 -3
- data/include/grpc/support/tls_pthread.h +1 -1
- data/include/grpc/support/useful.h +1 -1
- data/src/boringssl/err_data.c +258 -252
- data/src/core/{census → ext/census}/aggregation.h +3 -3
- data/src/core/{statistics → ext/census}/census_interface.h +3 -3
- data/src/core/{statistics → ext/census}/census_rpc_stats.h +4 -4
- data/src/core/{census → ext/census}/context.c +2 -2
- data/src/core/{census → ext/census}/grpc_context.c +2 -2
- data/src/core/{census → ext/census}/grpc_filter.c +30 -16
- data/src/core/{census → ext/census}/grpc_filter.h +4 -4
- data/src/core/ext/census/grpc_plugin.c +82 -0
- data/src/core/{census → ext/census}/initialize.c +1 -1
- data/src/core/{census → ext/census}/mlog.c +2 -2
- data/src/core/{census → ext/census}/mlog.h +4 -4
- data/src/core/{census → ext/census}/operation.c +0 -0
- data/src/core/{census → ext/census}/placeholders.c +0 -0
- data/src/core/{census → ext/census}/rpc_metric_id.h +3 -3
- data/src/core/{census → ext/census}/tracing.c +0 -0
- data/src/core/{surface → ext/client_config}/channel_connectivity.c +8 -21
- data/src/core/{channel → ext/client_config}/client_channel.c +80 -35
- data/src/core/{channel → ext/client_config}/client_channel.h +5 -5
- data/src/core/{client_config/subchannel_factory.c → ext/client_config/client_channel_factory.c} +14 -6
- data/src/core/ext/client_config/client_channel_factory.h +85 -0
- data/src/core/{client_config → ext/client_config}/client_config.c +4 -2
- data/src/core/{client_config → ext/client_config}/client_config.h +4 -4
- data/src/core/ext/client_config/client_config_plugin.c +95 -0
- data/src/core/{client_config → ext/client_config}/connector.c +2 -2
- data/src/core/{client_config → ext/client_config}/connector.h +7 -10
- data/src/core/{client_config → ext/client_config}/default_initial_connect_string.c +1 -1
- data/src/core/{client_config → ext/client_config}/initial_connect_string.c +1 -1
- data/src/core/{client_config → ext/client_config}/initial_connect_string.h +4 -4
- data/src/core/{client_config → ext/client_config}/lb_policy.c +12 -3
- data/src/core/{client_config → ext/client_config}/lb_policy.h +19 -6
- data/src/core/{client_config → ext/client_config}/lb_policy_factory.c +4 -3
- data/src/core/{client_config → ext/client_config}/lb_policy_factory.h +14 -9
- data/src/core/{client_config → ext/client_config}/lb_policy_registry.c +4 -9
- data/src/core/{client_config → ext/client_config}/lb_policy_registry.h +7 -6
- data/src/core/ext/client_config/parse_address.c +137 -0
- data/src/core/ext/client_config/parse_address.h +56 -0
- data/src/core/{client_config → ext/client_config}/resolver.c +1 -1
- data/src/core/{client_config → ext/client_config}/resolver.h +6 -6
- data/src/core/{client_config → ext/client_config}/resolver_factory.c +1 -1
- data/src/core/{client_config → ext/client_config}/resolver_factory.h +7 -7
- data/src/core/{client_config → ext/client_config}/resolver_registry.c +25 -11
- data/src/core/{client_config → ext/client_config}/resolver_registry.h +9 -5
- data/src/core/{client_config → ext/client_config}/subchannel.c +90 -126
- data/src/core/{client_config → ext/client_config}/subchannel.h +15 -15
- data/src/core/{channel → ext/client_config}/subchannel_call_holder.c +9 -8
- data/src/core/{channel → ext/client_config}/subchannel_call_holder.h +7 -7
- data/src/core/{client_config → ext/client_config}/subchannel_index.c +3 -2
- data/src/core/{client_config → ext/client_config}/subchannel_index.h +5 -5
- data/src/core/{client_config → ext/client_config}/uri_parser.c +69 -1
- data/src/core/{client_config → ext/client_config}/uri_parser.h +15 -3
- data/src/core/{client_config/lb_policies → ext/lb_policy/grpclb}/load_balancer_api.c +18 -9
- data/src/core/{client_config/lb_policies → ext/lb_policy/grpclb}/load_balancer_api.h +5 -5
- data/src/core/{proto → ext/lb_policy/grpclb/proto}/grpc/lb/v0/load_balancer.pb.c +1 -1
- data/src/core/{proto → ext/lb_policy/grpclb/proto}/grpc/lb/v0/load_balancer.pb.h +0 -0
- data/src/core/{client_config/lb_policies → ext/lb_policy/pick_first}/pick_first.c +95 -32
- data/src/core/{client_config/lb_policies → ext/lb_policy/round_robin}/round_robin.c +98 -34
- data/src/core/{client_config/resolvers → ext/resolver/dns/native}/dns_resolver.c +83 -39
- data/src/core/{client_config/resolvers → ext/resolver/sockaddr}/sockaddr_resolver.c +66 -169
- data/src/core/{transport/chttp2 → ext/transport/chttp2/alpn}/alpn.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/alpn}/alpn.h +3 -3
- data/src/core/{surface → ext/transport/chttp2/client/insecure}/channel_create.c +65 -59
- data/src/core/{surface → ext/transport/chttp2/client/secure}/secure_channel_create.c +77 -69
- data/src/core/{surface → ext/transport/chttp2/server/insecure}/server_chttp2.c +8 -11
- data/src/core/{security → ext/transport/chttp2/server/secure}/server_secure_chttp2.c +14 -17
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/bin_encoder.c +28 -74
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/bin_encoder.h +5 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +46 -0
- data/src/core/{transport → ext/transport/chttp2/transport}/chttp2_transport.c +551 -310
- data/src/core/{transport → ext/transport/chttp2/transport}/chttp2_transport.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_data.c +30 -14
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_data.h +10 -7
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_goaway.c +2 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_goaway.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_ping.c +2 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_ping.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_rst_stream.c +9 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_rst_stream.h +8 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_settings.c +6 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_settings.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_window_update.c +11 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_window_update.h +8 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_encoder.c +21 -12
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_encoder.h +8 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_parser.c +42 -25
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_parser.h +7 -7
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_table.c +21 -11
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_table.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/http2_errors.h +3 -3
- data/src/core/ext/transport/chttp2/transport/huffsyms.c +105 -0
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/huffsyms.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/incoming_metadata.c +2 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/incoming_metadata.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/internal.h +81 -37
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/parsing.c +54 -21
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/status_conversion.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/status_conversion.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/stream_lists.c +10 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/stream_map.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/stream_map.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/timeout_encoding.c +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/timeout_encoding.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/varint.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/varint.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/writing.c +30 -20
- data/src/core/{channel → lib/channel}/channel_args.c +3 -15
- data/src/core/{channel → lib/channel}/channel_args.h +11 -15
- data/src/core/{channel → lib/channel}/channel_stack.c +5 -3
- data/src/core/{channel → lib/channel}/channel_stack.h +13 -8
- data/src/core/lib/channel/channel_stack_builder.c +277 -0
- data/src/core/lib/channel/channel_stack_builder.h +161 -0
- data/src/core/{channel → lib/channel}/compress_filter.c +51 -16
- data/src/core/{channel → lib/channel}/compress_filter.h +6 -4
- data/src/core/{channel → lib/channel}/connected_channel.c +34 -24
- data/src/core/lib/channel/connected_channel.h +42 -0
- data/src/core/{channel → lib/channel}/context.h +3 -3
- data/src/core/{channel → lib/channel}/http_client_filter.c +24 -13
- data/src/core/{channel → lib/channel}/http_client_filter.h +4 -4
- data/src/core/{channel → lib/channel}/http_server_filter.c +39 -19
- data/src/core/{channel → lib/channel}/http_server_filter.h +4 -4
- data/src/core/{compression → lib/compression}/algorithm_metadata.h +4 -4
- data/src/core/{compression → lib/compression}/compression_algorithm.c +46 -9
- data/src/core/{compression → lib/compression}/message_compress.c +1 -1
- data/src/core/{compression → lib/compression}/message_compress.h +3 -3
- data/src/core/{debug → lib/debug}/trace.c +2 -2
- data/src/core/{debug → lib/debug}/trace.h +3 -3
- data/src/core/{httpcli → lib/http}/format_request.c +8 -8
- data/src/core/{httpcli → lib/http}/format_request.h +4 -4
- data/src/core/{httpcli → lib/http}/httpcli.c +24 -19
- data/src/core/{httpcli → lib/http}/httpcli.h +14 -33
- data/src/core/{httpcli → lib/http}/httpcli_security_connector.c +5 -5
- data/src/core/lib/http/parser.c +341 -0
- data/src/core/lib/http/parser.h +119 -0
- data/src/core/{iomgr → lib/iomgr}/closure.c +8 -2
- data/src/core/{iomgr → lib/iomgr}/closure.h +7 -4
- data/src/core/{iomgr → lib/iomgr}/endpoint.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/endpoint.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/endpoint_pair.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/endpoint_pair_posix.c +8 -7
- data/src/core/{iomgr → lib/iomgr}/endpoint_pair_windows.c +4 -4
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +1936 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.h +41 -0
- data/src/core/lib/iomgr/ev_posix.c +164 -0
- data/src/core/lib/iomgr/ev_posix.h +158 -0
- data/src/core/{iomgr → lib/iomgr}/exec_ctx.c +78 -3
- data/src/core/{iomgr → lib/iomgr}/exec_ctx.h +25 -10
- data/src/core/{iomgr → lib/iomgr}/executor.c +3 -3
- data/src/core/{iomgr → lib/iomgr}/executor.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/iocp_windows.c +6 -6
- data/src/core/{iomgr → lib/iomgr}/iocp_windows.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/iomgr.c +13 -10
- data/src/core/{iomgr → lib/iomgr}/iomgr.h +3 -3
- data/src/core/{iomgr → lib/iomgr}/iomgr_internal.h +5 -9
- data/src/core/{iomgr → lib/iomgr}/iomgr_posix.c +6 -6
- data/src/core/{iomgr → lib/iomgr}/iomgr_posix.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/iomgr_windows.c +7 -4
- data/src/core/{iomgr → lib/iomgr}/pollset.h +11 -11
- data/src/core/{iomgr → lib/iomgr}/pollset_set.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/pollset_set_windows.c +2 -2
- data/src/core/lib/iomgr/pollset_set_windows.h +39 -0
- data/src/core/{iomgr → lib/iomgr}/pollset_windows.c +7 -7
- data/src/core/{iomgr → lib/iomgr}/pollset_windows.h +8 -5
- data/src/core/{iomgr → lib/iomgr}/resolve_address.h +10 -9
- data/src/core/{iomgr → lib/iomgr}/resolve_address_posix.c +22 -22
- data/src/core/{iomgr → lib/iomgr}/resolve_address_windows.c +20 -12
- data/src/core/{iomgr → lib/iomgr}/sockaddr.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/sockaddr_posix.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/sockaddr_utils.c +9 -16
- data/src/core/{iomgr → lib/iomgr}/sockaddr_utils.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/sockaddr_win32.h +6 -4
- data/src/core/{iomgr → lib/iomgr}/socket_utils_common_posix.c +29 -7
- data/src/core/{iomgr → lib/iomgr}/socket_utils_linux.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/socket_utils_posix.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/socket_utils_posix.h +14 -4
- data/src/core/{iomgr → lib/iomgr}/socket_windows.c +7 -5
- data/src/core/{iomgr → lib/iomgr}/socket_windows.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_client.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_client_posix.c +33 -18
- data/src/core/{iomgr → lib/iomgr}/tcp_client_windows.c +30 -20
- data/src/core/{iomgr → lib/iomgr}/tcp_posix.c +9 -10
- data/src/core/{iomgr → lib/iomgr}/tcp_posix.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_server.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_server_posix.c +24 -37
- data/src/core/{iomgr → lib/iomgr}/tcp_server_windows.c +8 -36
- data/src/core/{iomgr → lib/iomgr}/tcp_windows.c +27 -17
- data/src/core/{iomgr → lib/iomgr}/tcp_windows.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/time_averaged_stats.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/time_averaged_stats.h +3 -3
- data/src/core/{iomgr → lib/iomgr}/timer.c +31 -4
- data/src/core/{iomgr → lib/iomgr}/timer.h +6 -7
- data/src/core/{iomgr → lib/iomgr}/timer_heap.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/timer_heap.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/udp_server.c +13 -37
- data/src/core/{iomgr → lib/iomgr}/udp_server.h +11 -10
- data/src/core/lib/iomgr/unix_sockets_posix.c +89 -0
- data/src/core/{client_config/resolvers/sockaddr_resolver.h → lib/iomgr/unix_sockets_posix.h} +15 -11
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +59 -0
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_eventfd.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_nospecial.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_pipe.c +8 -3
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_pipe.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_posix.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_posix.h +3 -3
- data/src/core/{iomgr → lib/iomgr}/workqueue.h +10 -10
- data/src/core/{iomgr → lib/iomgr}/workqueue_posix.c +5 -6
- data/src/core/{iomgr → lib/iomgr}/workqueue_posix.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/workqueue_windows.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/workqueue_windows.h +3 -3
- data/src/core/{json → lib/json}/json.c +1 -1
- data/src/core/{json → lib/json}/json.h +4 -4
- data/src/core/{json → lib/json}/json_common.h +3 -3
- data/src/core/{json → lib/json}/json_reader.c +16 -4
- data/src/core/{json → lib/json}/json_reader.h +4 -4
- data/src/core/{json → lib/json}/json_string.c +4 -4
- data/src/core/{json → lib/json}/json_writer.c +1 -1
- data/src/core/{json → lib/json}/json_writer.h +4 -4
- data/src/core/{profiling → lib/profiling}/basic_timers.c +3 -2
- data/src/core/{profiling → lib/profiling}/stap_timers.c +2 -2
- data/src/core/{profiling → lib/profiling}/timers.h +3 -3
- data/src/core/{security → lib/security}/auth_filters.h +4 -4
- data/src/core/{security → lib/security}/b64.c +2 -2
- data/src/core/{security → lib/security}/b64.h +4 -4
- data/src/core/{security → lib/security}/client_auth_filter.c +16 -16
- data/src/core/{security → lib/security}/credentials.c +42 -26
- data/src/core/{security → lib/security}/credentials.h +11 -10
- data/src/core/{security → lib/security}/credentials_metadata.c +1 -1
- data/src/core/{security → lib/security}/credentials_posix.c +3 -3
- data/src/core/{security → lib/security}/credentials_win32.c +3 -3
- data/src/core/{security → lib/security}/google_default_credentials.c +10 -9
- data/src/core/{security → lib/security}/handshake.c +4 -4
- data/src/core/{security → lib/security}/handshake.h +6 -6
- data/src/core/{security → lib/security}/json_token.c +4 -4
- data/src/core/{security → lib/security}/json_token.h +4 -4
- data/src/core/{security → lib/security}/jwt_verifier.c +14 -14
- data/src/core/{security → lib/security}/jwt_verifier.h +5 -5
- data/src/core/{security → lib/security}/secure_endpoint.c +9 -8
- data/src/core/{security → lib/security}/secure_endpoint.h +4 -4
- data/src/core/{security → lib/security}/security_connector.c +53 -21
- data/src/core/{security → lib/security}/security_connector.h +8 -8
- data/src/core/{security → lib/security}/security_context.c +5 -5
- data/src/core/{security → lib/security}/security_context.h +5 -5
- data/src/core/{security → lib/security}/server_auth_filter.c +9 -9
- data/src/core/{support → lib/support}/alloc.c +5 -3
- data/src/core/{support → lib/support}/avl.c +1 -1
- data/src/core/lib/support/backoff.c +76 -0
- data/src/core/lib/support/backoff.h +68 -0
- data/src/core/{support → lib/support}/block_annotate.h +3 -3
- data/src/core/{support → lib/support}/cmdline.c +1 -1
- data/src/core/{support → lib/support}/cpu_iphone.c +0 -0
- data/src/core/{support → lib/support}/cpu_linux.c +2 -2
- data/src/core/{support → lib/support}/cpu_posix.c +2 -2
- data/src/core/{support → lib/support}/cpu_windows.c +0 -0
- data/src/core/{support → lib/support}/env.h +3 -3
- data/src/core/{support → lib/support}/env_linux.c +3 -3
- data/src/core/{support → lib/support}/env_posix.c +2 -2
- data/src/core/{support → lib/support}/env_win32.c +27 -21
- data/src/core/{support → lib/support}/histogram.c +1 -1
- data/src/core/{support → lib/support}/host_port.c +1 -1
- data/src/core/{support → lib/support}/load_file.c +4 -4
- data/src/core/{support → lib/support}/load_file.h +4 -4
- data/src/core/{support → lib/support}/log.c +33 -0
- data/src/core/{support → lib/support}/log_android.c +2 -2
- data/src/core/{support → lib/support}/log_linux.c +6 -5
- data/src/core/{support → lib/support}/log_posix.c +3 -3
- data/src/core/{support → lib/support}/log_win32.c +8 -22
- data/src/core/{support → lib/support}/murmur_hash.c +1 -1
- data/src/core/{support → lib/support}/murmur_hash.h +3 -3
- data/src/core/{support → lib/support}/slice.c +0 -0
- data/src/core/{support → lib/support}/slice_buffer.c +0 -0
- data/src/core/{support → lib/support}/stack_lockfree.c +7 -7
- data/src/core/{support → lib/support}/stack_lockfree.h +3 -3
- data/src/core/{support → lib/support}/string.c +1 -1
- data/src/core/{support → lib/support}/string.h +4 -4
- data/src/core/{support → lib/support}/string_posix.c +1 -1
- data/src/core/{support/string_win32.c → lib/support/string_util_win32.c} +23 -38
- data/src/core/lib/support/string_win32.c +83 -0
- data/src/core/{support → lib/support}/string_win32.h +3 -3
- data/src/core/{support → lib/support}/subprocess_posix.c +3 -3
- data/src/core/{support → lib/support}/subprocess_windows.c +3 -3
- data/src/core/{support → lib/support}/sync.c +2 -2
- data/src/core/{support → lib/support}/sync_posix.c +3 -3
- data/src/core/{support → lib/support}/sync_win32.c +1 -1
- data/src/core/{support → lib/support}/thd.c +0 -0
- data/src/core/{support → lib/support}/thd_internal.h +3 -3
- data/src/core/{support → lib/support}/thd_posix.c +4 -3
- data/src/core/{support → lib/support}/thd_win32.c +1 -1
- data/src/core/{support → lib/support}/time.c +2 -2
- data/src/core/{support → lib/support}/time_posix.c +12 -6
- data/src/core/{support → lib/support}/time_precise.c +0 -0
- data/src/core/{support → lib/support}/time_precise.h +3 -3
- data/src/core/{support → lib/support}/time_win32.c +7 -7
- data/src/core/{support → lib/support}/tls_pthread.c +0 -0
- data/src/core/{support → lib/support}/tmpfile.h +4 -4
- data/src/core/lib/support/tmpfile_msys.c +73 -0
- data/src/core/{support → lib/support}/tmpfile_posix.c +5 -5
- data/src/core/{support → lib/support}/tmpfile_win32.c +5 -5
- data/src/core/{support → lib/support}/wrap_memcpy.c +0 -0
- data/src/core/{surface → lib/surface}/alarm.c +3 -3
- data/src/core/{surface → lib/surface}/api_trace.c +1 -1
- data/src/core/{surface → lib/surface}/api_trace.h +4 -4
- data/src/core/{surface → lib/surface}/byte_buffer.c +3 -3
- data/src/core/{surface → lib/surface}/byte_buffer_reader.c +3 -3
- data/src/core/{surface → lib/surface}/call.c +145 -73
- data/src/core/{surface → lib/surface}/call.h +14 -7
- data/src/core/{surface → lib/surface}/call_details.c +1 -1
- data/src/core/{surface → lib/surface}/call_log_batch.c +2 -2
- data/src/core/{surface → lib/surface}/call_test_only.h +3 -3
- data/src/core/{surface → lib/surface}/channel.c +33 -34
- data/src/core/{surface → lib/surface}/channel.h +9 -9
- data/src/core/lib/surface/channel_init.c +140 -0
- data/src/core/lib/surface/channel_init.h +87 -0
- data/src/core/{surface → lib/surface}/channel_ping.c +4 -4
- data/src/core/lib/surface/channel_stack_type.c +54 -0
- data/src/core/{httpcli/parser.h → lib/surface/channel_stack_type.h} +22 -28
- data/src/core/{surface → lib/surface}/completion_queue.c +15 -11
- data/src/core/{surface → lib/surface}/completion_queue.h +4 -4
- data/src/core/{surface → lib/surface}/event_string.c +2 -2
- data/src/core/{surface → lib/surface}/event_string.h +3 -3
- data/src/core/lib/surface/init.c +217 -0
- data/src/core/{surface → lib/surface}/init.h +4 -3
- data/src/core/lib/surface/init_secure.c +89 -0
- data/src/core/{surface → lib/surface}/lame_client.c +31 -19
- data/src/core/{iomgr/pollset_set_windows.h → lib/surface/lame_client.h} +7 -5
- data/src/core/{surface → lib/surface}/metadata_array.c +1 -1
- data/src/core/{surface → lib/surface}/server.c +208 -183
- data/src/core/{surface → lib/surface}/server.h +6 -11
- data/src/core/{surface → lib/surface}/surface_trace.h +5 -5
- data/src/core/{surface → lib/surface}/validate_metadata.c +1 -1
- data/src/core/{surface → lib/surface}/version.c +2 -2
- data/src/core/{transport → lib/transport}/byte_stream.c +1 -1
- data/src/core/{transport → lib/transport}/byte_stream.h +4 -4
- data/src/core/{transport → lib/transport}/connectivity_state.c +2 -2
- data/src/core/{transport → lib/transport}/connectivity_state.h +4 -4
- data/src/core/{transport → lib/transport}/metadata.c +71 -19
- data/src/core/{transport → lib/transport}/metadata.h +11 -4
- data/src/core/{transport → lib/transport}/metadata_batch.c +2 -2
- data/src/core/{transport → lib/transport}/metadata_batch.h +4 -4
- data/src/core/{transport → lib/transport}/static_metadata.c +100 -32
- data/src/core/{transport → lib/transport}/static_metadata.h +58 -58
- data/src/core/{transport → lib/transport}/transport.c +25 -5
- data/src/core/{transport → lib/transport}/transport.h +41 -16
- data/src/core/{transport → lib/transport}/transport_impl.h +8 -5
- data/src/core/{transport → lib/transport}/transport_op_string.c +2 -2
- data/src/core/{tsi → lib/tsi}/fake_transport_security.c +18 -14
- data/src/core/{tsi → lib/tsi}/fake_transport_security.h +4 -4
- data/src/core/{tsi → lib/tsi}/ssl_transport_security.c +173 -63
- data/src/core/{tsi → lib/tsi}/ssl_transport_security.h +24 -6
- data/src/core/{tsi → lib/tsi}/ssl_types.h +3 -3
- data/src/core/{tsi → lib/tsi}/transport_security.c +12 -28
- data/src/core/{tsi → lib/tsi}/transport_security.h +4 -4
- data/src/core/{tsi → lib/tsi}/transport_security_interface.h +12 -3
- data/src/core/plugin_registry/grpc_plugin_registry.c +66 -0
- data/src/ruby/ext/grpc/extconf.rb +14 -20
- data/src/ruby/ext/grpc/rb_byte_buffer.c +2 -3
- data/src/ruby/ext/grpc/rb_call.c +37 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +13 -3
- data/src/ruby/ext/grpc/rb_channel.c +2 -3
- data/src/ruby/ext/grpc/rb_channel_args.c +2 -3
- data/src/ruby/ext/grpc/rb_channel_credentials.c +31 -3
- data/src/ruby/ext/grpc/rb_completion_queue.c +2 -2
- data/src/ruby/ext/grpc/rb_event_thread.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +8 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +14 -2
- data/src/ruby/ext/grpc/rb_server.c +2 -3
- data/src/ruby/ext/grpc/rb_server_credentials.c +16 -13
- data/src/ruby/ext/grpc/rb_signal.c +70 -0
- data/src/ruby/ext/grpc/rb_signal.h +39 -0
- data/src/ruby/lib/grpc.rb +21 -13
- data/src/ruby/lib/grpc/core/time_consts.rb +2 -2
- data/src/ruby/lib/grpc/errors.rb +2 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +10 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +2 -2
- data/src/ruby/lib/grpc/generic/client_stub.rb +10 -7
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +2 -2
- data/src/ruby/lib/grpc/generic/rpc_server.rb +21 -61
- data/src/ruby/lib/grpc/generic/service.rb +5 -15
- data/src/ruby/lib/grpc/grpc.rb +3 -3
- data/src/ruby/{bin/interop/interop_server.rb → lib/grpc/signals.rb} +39 -20
- data/src/ruby/lib/grpc/version.rb +2 -2
- data/src/ruby/pb/generate_proto_ruby.sh +9 -2
- data/src/ruby/pb/grpc/health/checker.rb +1 -1
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics_services.rb +27 -0
- data/src/ruby/pb/test/client.rb +12 -23
- data/src/ruby/pb/test/server.rb +1 -1
- data/src/ruby/spec/client_server_spec.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +18 -17
- data/src/ruby/spec/generic/rpc_server_spec.rb +23 -7
- data/src/ruby/spec/generic/service_spec.rb +0 -69
- data/src/ruby/{bin/interop/interop_client.rb → spec/pb/duplicate/codegen_spec.rb} +41 -21
- data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +184 -176
- data/third_party/boringssl/crypto/asn1/a_bool.c +42 -44
- data/third_party/boringssl/crypto/asn1/a_bytes.c +236 -245
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +173 -192
- data/third_party/boringssl/crypto/asn1/a_dup.c +43 -35
- data/third_party/boringssl/crypto/asn1/a_enum.c +107 -109
- data/third_party/boringssl/crypto/asn1/a_gentm.c +180 -181
- data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +73 -80
- data/third_party/boringssl/crypto/asn1/a_int.c +357 -353
- data/third_party/boringssl/crypto/asn1/a_mbstr.c +272 -253
- data/third_party/boringssl/crypto/asn1/a_object.c +293 -309
- data/third_party/boringssl/crypto/asn1/a_octet.c +13 -6
- data/third_party/boringssl/crypto/asn1/a_print.c +54 -52
- data/third_party/boringssl/crypto/asn1/a_strnid.c +179 -157
- data/third_party/boringssl/crypto/asn1/a_time.c +125 -129
- data/third_party/boringssl/crypto/asn1/a_type.c +79 -86
- data/third_party/boringssl/crypto/asn1/a_utctm.c +246 -255
- data/third_party/boringssl/crypto/asn1/a_utf8.c +159 -135
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +361 -368
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +11 -11
- data/third_party/boringssl/crypto/asn1/asn1_par.c +309 -351
- data/third_party/boringssl/crypto/asn1/asn_pack.c +30 -29
- data/third_party/boringssl/crypto/asn1/bio_asn1.c +375 -394
- data/third_party/boringssl/crypto/asn1/bio_ndef.c +146 -149
- data/third_party/boringssl/crypto/asn1/f_enum.c +128 -134
- data/third_party/boringssl/crypto/asn1/f_int.c +131 -139
- data/third_party/boringssl/crypto/asn1/f_string.c +125 -133
- data/third_party/boringssl/crypto/asn1/t_bitst.c +30 -29
- data/third_party/boringssl/crypto/asn1/t_pkey.c +45 -47
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +1099 -1216
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +556 -592
- data/third_party/boringssl/crypto/asn1/tasn_fre.c +175 -193
- data/third_party/boringssl/crypto/asn1/tasn_new.c +271 -288
- data/third_party/boringssl/crypto/asn1/tasn_prn.c +462 -508
- data/third_party/boringssl/crypto/asn1/tasn_typ.c +28 -21
- data/third_party/boringssl/crypto/asn1/x_bignum.c +62 -52
- data/third_party/boringssl/crypto/asn1/x_long.c +101 -86
- data/third_party/boringssl/crypto/bio/buffer.c +3 -3
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +8 -68
- data/third_party/boringssl/crypto/bn/bn.c +1 -1
- data/third_party/boringssl/crypto/bn/bn_asn1.c +9 -22
- data/third_party/boringssl/crypto/bn/convert.c +9 -4
- data/third_party/boringssl/crypto/bn/div.c +0 -20
- data/third_party/boringssl/crypto/bn/exponentiation.c +22 -13
- data/third_party/boringssl/crypto/bn/generic.c +6 -242
- data/third_party/boringssl/crypto/bn/internal.h +9 -70
- data/third_party/boringssl/crypto/bn/montgomery.c +1 -2
- data/third_party/boringssl/crypto/bn/mul.c +6 -26
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +21 -28
- data/third_party/boringssl/crypto/bytestring/asn1_compat.c +51 -0
- data/third_party/boringssl/crypto/bytestring/ber.c +128 -87
- data/third_party/boringssl/crypto/bytestring/cbb.c +37 -3
- data/third_party/boringssl/crypto/bytestring/internal.h +39 -10
- data/third_party/boringssl/crypto/chacha/chacha_vec.c +18 -13
- data/third_party/boringssl/crypto/cipher/e_aes.c +2 -2
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +4 -9
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +39 -10
- data/third_party/boringssl/crypto/conf/conf.c +9 -0
- data/third_party/boringssl/crypto/cpu-intel.c +1 -1
- data/third_party/boringssl/crypto/crypto.c +2 -0
- data/third_party/boringssl/crypto/curve25519/curve25519.c +125 -120
- data/third_party/boringssl/crypto/curve25519/internal.h +45 -0
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +225 -0
- data/third_party/boringssl/crypto/dh/check.c +32 -10
- data/third_party/boringssl/crypto/dh/dh.c +1 -1
- data/third_party/boringssl/crypto/digest/md32_common.h +0 -60
- data/third_party/boringssl/crypto/dsa/dsa.c +47 -21
- data/third_party/boringssl/crypto/dsa/dsa_asn1.c +249 -64
- data/third_party/boringssl/crypto/ec/ec.c +45 -31
- data/third_party/boringssl/crypto/ec/ec_asn1.c +315 -382
- data/third_party/boringssl/crypto/ec/ec_key.c +1 -4
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +0 -9
- data/third_party/boringssl/crypto/ec/internal.h +1 -19
- data/third_party/boringssl/crypto/ec/oct.c +12 -0
- data/third_party/boringssl/crypto/ec/p224-64.c +4 -65
- data/third_party/boringssl/crypto/ec/p256-64.c +9 -71
- data/third_party/boringssl/crypto/ec/p256-x86_64-table.h +1 -6
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +3 -13
- data/third_party/boringssl/crypto/ec/simple.c +0 -76
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +1 -1
- data/third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c +10 -24
- data/third_party/boringssl/crypto/evp/evp.c +4 -3
- data/third_party/boringssl/crypto/evp/evp_asn1.c +101 -0
- data/third_party/boringssl/crypto/evp/evp_ctx.c +22 -51
- data/third_party/boringssl/crypto/evp/internal.h +28 -27
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +78 -249
- data/third_party/boringssl/crypto/evp/p_ec.c +19 -66
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +74 -231
- data/third_party/boringssl/crypto/evp/p_rsa.c +90 -13
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +49 -48
- data/third_party/boringssl/crypto/internal.h +16 -1
- data/third_party/boringssl/crypto/mem.c +2 -2
- data/third_party/boringssl/crypto/modes/ctr.c +2 -1
- data/third_party/boringssl/crypto/modes/gcm.c +5 -3
- data/third_party/boringssl/crypto/obj/obj_dat.h +6 -3
- data/third_party/boringssl/crypto/pem/pem_all.c +83 -102
- data/third_party/boringssl/crypto/pem/pem_info.c +286 -309
- data/third_party/boringssl/crypto/pem/pem_lib.c +690 -710
- data/third_party/boringssl/crypto/pem/pem_oth.c +15 -16
- data/third_party/boringssl/crypto/pem/pem_pk8.c +132 -119
- data/third_party/boringssl/crypto/pem/pem_pkey.c +144 -220
- data/third_party/boringssl/crypto/pem/pem_x509.c +3 -3
- data/third_party/boringssl/crypto/pem/pem_xaux.c +5 -4
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +54 -60
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +3 -1
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +48 -50
- data/third_party/boringssl/crypto/rand/rand.c +2 -0
- data/third_party/boringssl/crypto/rsa/blinding.c +8 -48
- data/third_party/boringssl/crypto/rsa/internal.h +1 -9
- data/third_party/boringssl/crypto/rsa/padding.c +73 -77
- data/third_party/boringssl/crypto/rsa/rsa.c +1 -1
- data/third_party/boringssl/crypto/rsa/rsa_asn1.c +27 -46
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +23 -34
- data/third_party/boringssl/crypto/test/scoped_types.h +3 -0
- data/third_party/boringssl/crypto/thread_win.c +15 -13
- data/third_party/boringssl/crypto/time_support.c +0 -6
- data/third_party/boringssl/crypto/x509/a_digest.c +26 -27
- data/third_party/boringssl/crypto/x509/a_sign.c +63 -64
- data/third_party/boringssl/crypto/x509/a_strex.c +482 -413
- data/third_party/boringssl/crypto/x509/a_verify.c +45 -51
- data/third_party/boringssl/crypto/x509/asn1_gen.c +715 -769
- data/third_party/boringssl/crypto/x509/by_dir.c +355 -393
- data/third_party/boringssl/crypto/x509/by_file.c +186 -206
- data/third_party/boringssl/crypto/x509/charmap.h +11 -11
- data/third_party/boringssl/crypto/x509/i2d_pr.c +21 -22
- data/third_party/boringssl/crypto/x509/t_crl.c +50 -51
- data/third_party/boringssl/crypto/x509/t_x509.c +414 -406
- data/third_party/boringssl/crypto/x509/t_x509a.c +44 -42
- data/third_party/boringssl/crypto/x509/vpm_int.h +13 -13
- data/third_party/boringssl/crypto/x509/x509_att.c +241 -219
- data/third_party/boringssl/crypto/x509/x509_cmp.c +343 -359
- data/third_party/boringssl/crypto/x509/x509_d2.c +36 -35
- data/third_party/boringssl/crypto/x509/x509_def.c +23 -13
- data/third_party/boringssl/crypto/x509/x509_ext.c +75 -75
- data/third_party/boringssl/crypto/x509/x509_lu.c +574 -612
- data/third_party/boringssl/crypto/x509/x509_obj.c +104 -115
- data/third_party/boringssl/crypto/x509/x509_r2x.c +40 -40
- data/third_party/boringssl/crypto/x509/x509_req.c +181 -174
- data/third_party/boringssl/crypto/x509/x509_set.c +71 -76
- data/third_party/boringssl/crypto/x509/x509_trs.c +193 -171
- data/third_party/boringssl/crypto/x509/x509_txt.c +135 -138
- data/third_party/boringssl/crypto/x509/x509_v3.c +174 -167
- data/third_party/boringssl/crypto/x509/x509_vfy.c +2079 -2130
- data/third_party/boringssl/crypto/x509/x509_vpm.c +486 -522
- data/third_party/boringssl/crypto/x509/x509cset.c +96 -99
- data/third_party/boringssl/crypto/x509/x509name.c +280 -275
- data/third_party/boringssl/crypto/x509/x509rset.c +15 -14
- data/third_party/boringssl/crypto/x509/x509spki.c +62 -60
- data/third_party/boringssl/crypto/x509/x509type.c +58 -60
- data/third_party/boringssl/crypto/x509/x_algor.c +70 -73
- data/third_party/boringssl/crypto/x509/x_all.c +282 -328
- data/third_party/boringssl/crypto/x509/x_attrib.c +36 -42
- data/third_party/boringssl/crypto/x509/x_crl.c +397 -418
- data/third_party/boringssl/crypto/x509/x_exten.c +5 -5
- data/third_party/boringssl/crypto/x509/x_info.c +30 -27
- data/third_party/boringssl/crypto/x509/x_name.c +387 -388
- data/third_party/boringssl/crypto/x509/x_pkey.c +32 -29
- data/third_party/boringssl/crypto/x509/x_pubkey.c +261 -280
- data/third_party/boringssl/crypto/x509/x_req.c +30 -33
- data/third_party/boringssl/crypto/x509/x_sig.c +2 -2
- data/third_party/boringssl/crypto/x509/x_spki.c +9 -7
- data/third_party/boringssl/crypto/x509/x_val.c +2 -2
- data/third_party/boringssl/crypto/x509/x_x509.c +120 -119
- data/third_party/boringssl/crypto/x509/x_x509a.c +99 -91
- data/third_party/boringssl/crypto/x509v3/ext_dat.h +57 -51
- data/third_party/boringssl/crypto/x509v3/pcy_cache.c +199 -214
- data/third_party/boringssl/crypto/x509v3/pcy_data.c +57 -64
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +95 -90
- data/third_party/boringssl/crypto/x509v3/pcy_lib.c +86 -87
- data/third_party/boringssl/crypto/x509v3/pcy_map.c +61 -64
- data/third_party/boringssl/crypto/x509v3/pcy_node.c +108 -117
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +676 -724
- data/third_party/boringssl/crypto/x509v3/v3_akey.c +128 -136
- data/third_party/boringssl/crypto/x509v3/v3_akeya.c +7 -6
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +499 -507
- data/third_party/boringssl/crypto/x509v3/v3_bcons.c +54 -47
- data/third_party/boringssl/crypto/x509v3/v3_bitst.c +67 -67
- data/third_party/boringssl/crypto/x509v3/v3_conf.c +330 -328
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +354 -338
- data/third_party/boringssl/crypto/x509v3/v3_crld.c +441 -496
- data/third_party/boringssl/crypto/x509v3/v3_enum.c +35 -33
- data/third_party/boringssl/crypto/x509v3/v3_extku.c +66 -63
- data/third_party/boringssl/crypto/x509v3/v3_genn.c +157 -159
- data/third_party/boringssl/crypto/x509v3/v3_ia5.c +45 -43
- data/third_party/boringssl/crypto/x509v3/v3_info.c +124 -112
- data/third_party/boringssl/crypto/x509v3/v3_int.c +30 -26
- data/third_party/boringssl/crypto/x509v3/v3_lib.c +231 -204
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +353 -381
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +252 -270
- data/third_party/boringssl/crypto/x509v3/v3_pcia.c +9 -8
- data/third_party/boringssl/crypto/x509v3/v3_pcons.c +58 -61
- data/third_party/boringssl/crypto/x509v3/v3_pku.c +35 -34
- data/third_party/boringssl/crypto/x509v3/v3_pmaps.c +72 -74
- data/third_party/boringssl/crypto/x509v3/v3_prn.c +146 -121
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +651 -582
- data/third_party/boringssl/crypto/x509v3/v3_skey.c +76 -72
- data/third_party/boringssl/crypto/x509v3/v3_sxnet.c +139 -131
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +1072 -1068
- data/third_party/boringssl/include/openssl/asn1.h +40 -38
- data/third_party/boringssl/include/openssl/base.h +10 -1
- data/third_party/boringssl/include/openssl/bio.h +10 -11
- data/third_party/boringssl/include/openssl/bn.h +12 -9
- data/third_party/boringssl/include/openssl/buf.h +1 -1
- data/third_party/boringssl/include/openssl/bytestring.h +29 -0
- data/third_party/boringssl/include/openssl/conf.h +25 -0
- data/third_party/boringssl/include/openssl/crypto.h +6 -1
- data/third_party/boringssl/include/openssl/curve25519.h +6 -3
- data/third_party/boringssl/include/openssl/dh.h +7 -3
- data/third_party/boringssl/include/openssl/dsa.h +108 -51
- data/third_party/boringssl/include/openssl/ec.h +46 -21
- data/third_party/boringssl/include/openssl/ec_key.h +78 -42
- data/third_party/boringssl/include/openssl/ecdsa.h +4 -4
- data/third_party/boringssl/include/openssl/err.h +3 -2
- data/third_party/boringssl/include/openssl/evp.h +120 -37
- data/third_party/boringssl/include/openssl/mem.h +4 -13
- data/third_party/boringssl/include/openssl/obj_mac.h +4 -0
- data/third_party/boringssl/include/openssl/pem.h +0 -9
- data/third_party/boringssl/include/openssl/pkcs8.h +6 -2
- data/third_party/boringssl/include/openssl/rand.h +3 -0
- data/third_party/boringssl/include/openssl/rsa.h +42 -42
- data/third_party/boringssl/include/openssl/ssl.h +115 -41
- data/third_party/boringssl/include/openssl/stack.h +0 -3
- data/third_party/boringssl/include/openssl/stack_macros.h +0 -256
- data/third_party/boringssl/include/openssl/tls1.h +1 -1
- data/third_party/boringssl/include/openssl/x509.h +0 -2
- data/third_party/boringssl/include/openssl/x509_vfy.h +5 -0
- data/third_party/boringssl/ssl/d1_both.c +102 -101
- data/third_party/boringssl/ssl/d1_clnt.c +145 -150
- data/third_party/boringssl/ssl/d1_lib.c +63 -62
- data/third_party/boringssl/ssl/d1_pkt.c +73 -71
- data/third_party/boringssl/ssl/d1_srvr.c +116 -125
- data/third_party/boringssl/ssl/dtls_record.c +3 -3
- data/third_party/boringssl/ssl/internal.h +210 -208
- data/third_party/boringssl/ssl/pqueue/pqueue.c +2 -2
- data/third_party/boringssl/ssl/s3_both.c +116 -130
- data/third_party/boringssl/ssl/s3_clnt.c +589 -740
- data/third_party/boringssl/ssl/s3_enc.c +52 -151
- data/third_party/boringssl/ssl/s3_lib.c +70 -76
- data/third_party/boringssl/ssl/s3_pkt.c +105 -144
- data/third_party/boringssl/ssl/s3_srvr.c +542 -806
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +1 -1
- data/third_party/boringssl/ssl/ssl_cert.c +2 -2
- data/third_party/boringssl/ssl/ssl_cipher.c +7 -3
- data/third_party/boringssl/ssl/ssl_ecdh.c +374 -0
- data/third_party/boringssl/ssl/ssl_lib.c +260 -221
- data/third_party/boringssl/ssl/ssl_session.c +17 -17
- data/third_party/boringssl/ssl/t1_enc.c +128 -273
- data/third_party/boringssl/ssl/t1_lib.c +134 -258
- data/third_party/boringssl/ssl/test/test_config.h +2 -0
- data/third_party/boringssl/ssl/tls_record.c +52 -15
- metadata +385 -359
- data/src/core/channel/client_uchannel.c +0 -243
- data/src/core/channel/client_uchannel.h +0 -60
- data/src/core/channel/connected_channel.h +0 -51
- data/src/core/client_config/lb_policies/pick_first.h +0 -43
- data/src/core/client_config/resolvers/dns_resolver.h +0 -42
- data/src/core/client_config/subchannel_factory.h +0 -66
- data/src/core/httpcli/parser.c +0 -211
- data/src/core/iomgr/fd_posix.c +0 -451
- data/src/core/iomgr/fd_posix.h +0 -192
- data/src/core/iomgr/pollset_multipoller_with_epoll.c +0 -324
- data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +0 -234
- data/src/core/iomgr/pollset_posix.c +0 -633
- data/src/core/iomgr/pollset_posix.h +0 -153
- data/src/core/iomgr/pollset_set_posix.c +0 -202
- data/src/core/iomgr/pollset_set_posix.h +0 -45
- data/src/core/surface/init.c +0 -174
- data/src/core/surface/init_secure.c +0 -42
- data/src/core/surface/server_create.c +0 -48
- data/src/core/transport/chttp2/huffsyms.c +0 -297
- data/src/ruby/bin/grpc_ruby_interop_client +0 -33
- data/src/ruby/bin/grpc_ruby_interop_server +0 -33
- data/third_party/boringssl/crypto/dsa/internal.h +0 -78
@@ -71,27 +71,26 @@
|
|
71
71
|
#include "vpm_int.h"
|
72
72
|
#include "../internal.h"
|
73
73
|
|
74
|
-
|
75
74
|
static CRYPTO_EX_DATA_CLASS g_ex_data_class =
|
76
|
-
|
75
|
+
CRYPTO_EX_DATA_CLASS_INIT_WITH_APP_DATA;
|
77
76
|
|
78
77
|
/* CRL score values */
|
79
78
|
|
80
79
|
/* No unhandled critical extensions */
|
81
80
|
|
82
|
-
#define CRL_SCORE_NOCRITICAL
|
81
|
+
#define CRL_SCORE_NOCRITICAL 0x100
|
83
82
|
|
84
83
|
/* certificate is within CRL scope */
|
85
84
|
|
86
|
-
#define CRL_SCORE_SCOPE
|
85
|
+
#define CRL_SCORE_SCOPE 0x080
|
87
86
|
|
88
87
|
/* CRL times valid */
|
89
88
|
|
90
|
-
#define CRL_SCORE_TIME
|
89
|
+
#define CRL_SCORE_TIME 0x040
|
91
90
|
|
92
91
|
/* Issuer name matches certificate */
|
93
92
|
|
94
|
-
#define CRL_SCORE_ISSUER_NAME
|
93
|
+
#define CRL_SCORE_ISSUER_NAME 0x020
|
95
94
|
|
96
95
|
/* If this score or above CRL is probably valid */
|
97
96
|
|
@@ -99,21 +98,21 @@ static CRYPTO_EX_DATA_CLASS g_ex_data_class =
|
|
99
98
|
|
100
99
|
/* CRL issuer is certificate issuer */
|
101
100
|
|
102
|
-
#define CRL_SCORE_ISSUER_CERT
|
101
|
+
#define CRL_SCORE_ISSUER_CERT 0x018
|
103
102
|
|
104
103
|
/* CRL issuer is on certificate path */
|
105
104
|
|
106
|
-
#define CRL_SCORE_SAME_PATH
|
105
|
+
#define CRL_SCORE_SAME_PATH 0x008
|
107
106
|
|
108
107
|
/* CRL issuer matches CRL AKID */
|
109
108
|
|
110
|
-
#define CRL_SCORE_AKID
|
109
|
+
#define CRL_SCORE_AKID 0x004
|
111
110
|
|
112
111
|
/* Have a delta CRL with valid times */
|
113
112
|
|
114
|
-
#define CRL_SCORE_TIME_DELTA
|
113
|
+
#define CRL_SCORE_TIME_DELTA 0x002
|
115
114
|
|
116
|
-
static int null_callback(int ok,X509_STORE_CTX *e);
|
115
|
+
static int null_callback(int ok, X509_STORE_CTX *e);
|
117
116
|
static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
|
118
117
|
static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x);
|
119
118
|
static int check_chain_extensions(X509_STORE_CTX *ctx);
|
@@ -125,2332 +124,2282 @@ static int check_cert(X509_STORE_CTX *ctx);
|
|
125
124
|
static int check_policy(X509_STORE_CTX *ctx);
|
126
125
|
|
127
126
|
static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
|
128
|
-
|
129
|
-
X509_CRL *crl, X509 *x);
|
127
|
+
unsigned int *preasons, X509_CRL *crl, X509 *x);
|
130
128
|
static int get_crl_delta(X509_STORE_CTX *ctx,
|
131
|
-
|
132
|
-
static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl,
|
133
|
-
|
134
|
-
|
135
|
-
|
129
|
+
X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x);
|
130
|
+
static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl,
|
131
|
+
int *pcrl_score, X509_CRL *base,
|
132
|
+
STACK_OF(X509_CRL) *crls);
|
133
|
+
static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl, X509 **pissuer,
|
134
|
+
int *pcrl_score);
|
136
135
|
static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score,
|
137
|
-
|
136
|
+
unsigned int *preasons);
|
138
137
|
static int check_crl_path(X509_STORE_CTX *ctx, X509 *x);
|
139
138
|
static int check_crl_chain(X509_STORE_CTX *ctx,
|
140
|
-
|
141
|
-
|
139
|
+
STACK_OF(X509) *cert_path,
|
140
|
+
STACK_OF(X509) *crl_path);
|
142
141
|
|
143
142
|
static int internal_verify(X509_STORE_CTX *ctx);
|
144
143
|
|
145
|
-
|
146
144
|
static int null_callback(int ok, X509_STORE_CTX *e)
|
147
|
-
|
148
|
-
|
149
|
-
|
145
|
+
{
|
146
|
+
return ok;
|
147
|
+
}
|
150
148
|
|
151
149
|
#if 0
|
152
150
|
static int x509_subject_cmp(X509 **a, X509 **b)
|
153
|
-
|
154
|
-
|
155
|
-
|
151
|
+
{
|
152
|
+
return X509_subject_name_cmp(*a, *b);
|
153
|
+
}
|
156
154
|
#endif
|
157
155
|
/* Return 1 is a certificate is self signed */
|
158
156
|
static int cert_self_signed(X509 *x)
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
157
|
+
{
|
158
|
+
X509_check_purpose(x, -1, 0);
|
159
|
+
if (x->ex_flags & EXFLAG_SS)
|
160
|
+
return 1;
|
161
|
+
else
|
162
|
+
return 0;
|
163
|
+
}
|
166
164
|
|
167
165
|
/* Given a certificate try and find an exact match in the store */
|
168
166
|
|
169
167
|
static X509 *lookup_cert_match(X509_STORE_CTX *ctx, X509 *x)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
}
|
168
|
+
{
|
169
|
+
STACK_OF(X509) *certs;
|
170
|
+
X509 *xtmp = NULL;
|
171
|
+
size_t i;
|
172
|
+
/* Lookup all certs with matching subject name */
|
173
|
+
certs = ctx->lookup_certs(ctx, X509_get_subject_name(x));
|
174
|
+
if (certs == NULL)
|
175
|
+
return NULL;
|
176
|
+
/* Look for exact match */
|
177
|
+
for (i = 0; i < sk_X509_num(certs); i++) {
|
178
|
+
xtmp = sk_X509_value(certs, i);
|
179
|
+
if (!X509_cmp(xtmp, x))
|
180
|
+
break;
|
181
|
+
}
|
182
|
+
if (i < sk_X509_num(certs))
|
183
|
+
X509_up_ref(xtmp);
|
184
|
+
else
|
185
|
+
xtmp = NULL;
|
186
|
+
sk_X509_pop_free(certs, X509_free);
|
187
|
+
return xtmp;
|
188
|
+
}
|
192
189
|
|
193
190
|
int X509_verify_cert(X509_STORE_CTX *ctx)
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
191
|
+
{
|
192
|
+
X509 *x, *xtmp, *xtmp2, *chain_ss = NULL;
|
193
|
+
int bad_chain = 0;
|
194
|
+
X509_VERIFY_PARAM *param = ctx->param;
|
195
|
+
int depth, i, ok = 0;
|
196
|
+
int num, j, retry;
|
197
|
+
int (*cb) (int xok, X509_STORE_CTX *xctx);
|
198
|
+
STACK_OF(X509) *sktmp = NULL;
|
199
|
+
if (ctx->cert == NULL) {
|
200
|
+
OPENSSL_PUT_ERROR(X509, X509_R_NO_CERT_SET_FOR_US_TO_VERIFY);
|
201
|
+
return -1;
|
202
|
+
}
|
203
|
+
if (ctx->chain != NULL) {
|
204
|
+
/*
|
205
|
+
* This X509_STORE_CTX has already been used to verify a cert. We
|
206
|
+
* cannot do another one.
|
207
|
+
*/
|
208
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
209
|
+
return -1;
|
210
|
+
}
|
211
|
+
|
212
|
+
cb = ctx->verify_cb;
|
213
|
+
|
214
|
+
/*
|
215
|
+
* first we make sure the chain we are going to build is present and that
|
216
|
+
* the first entry is in place
|
217
|
+
*/
|
218
|
+
ctx->chain = sk_X509_new_null();
|
219
|
+
if (ctx->chain == NULL || !sk_X509_push(ctx->chain, ctx->cert)) {
|
220
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
221
|
+
goto end;
|
222
|
+
}
|
223
|
+
X509_up_ref(ctx->cert);
|
224
|
+
ctx->last_untrusted = 1;
|
225
|
+
|
226
|
+
/* We use a temporary STACK so we can chop and hack at it */
|
227
|
+
if (ctx->untrusted != NULL
|
228
|
+
&& (sktmp = sk_X509_dup(ctx->untrusted)) == NULL) {
|
229
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
230
|
+
goto end;
|
231
|
+
}
|
232
|
+
|
233
|
+
num = sk_X509_num(ctx->chain);
|
234
|
+
x = sk_X509_value(ctx->chain, num - 1);
|
235
|
+
depth = param->depth;
|
236
|
+
|
237
|
+
for (;;) {
|
238
|
+
/* If we have enough, we break */
|
239
|
+
if (depth < num)
|
240
|
+
break; /* FIXME: If this happens, we should take
|
241
|
+
* note of it and, if appropriate, use the
|
242
|
+
* X509_V_ERR_CERT_CHAIN_TOO_LONG error code
|
243
|
+
* later. */
|
244
|
+
|
245
|
+
/* If we are self signed, we break */
|
246
|
+
if (cert_self_signed(x))
|
247
|
+
break;
|
248
|
+
/*
|
249
|
+
* If asked see if we can find issuer in trusted store first
|
250
|
+
*/
|
251
|
+
if (ctx->param->flags & X509_V_FLAG_TRUSTED_FIRST) {
|
252
|
+
ok = ctx->get_issuer(&xtmp, ctx, x);
|
253
|
+
if (ok < 0)
|
254
|
+
goto end;
|
255
|
+
/*
|
256
|
+
* If successful for now free up cert so it will be picked up
|
257
|
+
* again later.
|
258
|
+
*/
|
259
|
+
if (ok > 0) {
|
260
|
+
X509_free(xtmp);
|
261
|
+
break;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
/* If we were passed a cert chain, use it first */
|
266
|
+
if (ctx->untrusted != NULL) {
|
267
|
+
xtmp = find_issuer(ctx, sktmp, x);
|
268
|
+
if (xtmp != NULL) {
|
269
|
+
if (!sk_X509_push(ctx->chain, xtmp)) {
|
270
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
271
|
+
goto end;
|
272
|
+
}
|
273
|
+
X509_up_ref(xtmp);
|
274
|
+
(void)sk_X509_delete_ptr(sktmp, xtmp);
|
275
|
+
ctx->last_untrusted++;
|
276
|
+
x = xtmp;
|
277
|
+
num++;
|
278
|
+
/*
|
279
|
+
* reparse the full chain for the next one
|
280
|
+
*/
|
281
|
+
continue;
|
282
|
+
}
|
283
|
+
}
|
284
|
+
break;
|
285
|
+
}
|
286
|
+
|
287
|
+
/* Remember how many untrusted certs we have */
|
288
|
+
j = num;
|
289
|
+
/*
|
290
|
+
* at this point, chain should contain a list of untrusted certificates.
|
291
|
+
* We now need to add at least one trusted one, if possible, otherwise we
|
292
|
+
* complain.
|
293
|
+
*/
|
294
|
+
|
295
|
+
do {
|
296
|
+
/*
|
297
|
+
* Examine last certificate in chain and see if it is self signed.
|
298
|
+
*/
|
299
|
+
i = sk_X509_num(ctx->chain);
|
300
|
+
x = sk_X509_value(ctx->chain, i - 1);
|
301
|
+
if (cert_self_signed(x)) {
|
302
|
+
/* we have a self signed certificate */
|
303
|
+
if (sk_X509_num(ctx->chain) == 1) {
|
304
|
+
/*
|
305
|
+
* We have a single self signed certificate: see if we can
|
306
|
+
* find it in the store. We must have an exact match to avoid
|
307
|
+
* possible impersonation.
|
308
|
+
*/
|
309
|
+
ok = ctx->get_issuer(&xtmp, ctx, x);
|
310
|
+
if ((ok <= 0) || X509_cmp(x, xtmp)) {
|
311
|
+
ctx->error = X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;
|
312
|
+
ctx->current_cert = x;
|
313
|
+
ctx->error_depth = i - 1;
|
314
|
+
if (ok == 1)
|
315
|
+
X509_free(xtmp);
|
316
|
+
bad_chain = 1;
|
317
|
+
ok = cb(0, ctx);
|
318
|
+
if (!ok)
|
319
|
+
goto end;
|
320
|
+
} else {
|
321
|
+
/*
|
322
|
+
* We have a match: replace certificate with store
|
323
|
+
* version so we get any trust settings.
|
324
|
+
*/
|
325
|
+
X509_free(x);
|
326
|
+
x = xtmp;
|
327
|
+
(void)sk_X509_set(ctx->chain, i - 1, x);
|
328
|
+
ctx->last_untrusted = 0;
|
329
|
+
}
|
330
|
+
} else {
|
331
|
+
/*
|
332
|
+
* extract and save self signed certificate for later use
|
333
|
+
*/
|
334
|
+
chain_ss = sk_X509_pop(ctx->chain);
|
335
|
+
ctx->last_untrusted--;
|
336
|
+
num--;
|
337
|
+
j--;
|
338
|
+
x = sk_X509_value(ctx->chain, num - 1);
|
339
|
+
}
|
340
|
+
}
|
341
|
+
/* We now lookup certs from the certificate store */
|
342
|
+
for (;;) {
|
343
|
+
/* If we have enough, we break */
|
344
|
+
if (depth < num)
|
345
|
+
break;
|
346
|
+
/* If we are self signed, we break */
|
347
|
+
if (cert_self_signed(x))
|
348
|
+
break;
|
349
|
+
ok = ctx->get_issuer(&xtmp, ctx, x);
|
350
|
+
|
351
|
+
if (ok < 0)
|
352
|
+
goto end;
|
353
|
+
if (ok == 0)
|
354
|
+
break;
|
355
|
+
x = xtmp;
|
356
|
+
if (!sk_X509_push(ctx->chain, x)) {
|
357
|
+
X509_free(xtmp);
|
358
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
359
|
+
ok = 0;
|
360
|
+
goto end;
|
361
|
+
}
|
362
|
+
num++;
|
363
|
+
}
|
364
|
+
|
365
|
+
/* we now have our chain, lets check it... */
|
366
|
+
i = check_trust(ctx);
|
367
|
+
|
368
|
+
/* If explicitly rejected error */
|
369
|
+
if (i == X509_TRUST_REJECTED)
|
370
|
+
goto end;
|
371
|
+
/*
|
372
|
+
* If it's not explicitly trusted then check if there is an alternative
|
373
|
+
* chain that could be used. We only do this if we haven't already
|
374
|
+
* checked via TRUSTED_FIRST and the user hasn't switched off alternate
|
375
|
+
* chain checking
|
376
|
+
*/
|
377
|
+
retry = 0;
|
378
|
+
if (i != X509_TRUST_TRUSTED
|
379
|
+
&& !(ctx->param->flags & X509_V_FLAG_TRUSTED_FIRST)
|
380
|
+
&& !(ctx->param->flags & X509_V_FLAG_NO_ALT_CHAINS)) {
|
381
|
+
while (j-- > 1) {
|
382
|
+
xtmp2 = sk_X509_value(ctx->chain, j - 1);
|
383
|
+
ok = ctx->get_issuer(&xtmp, ctx, xtmp2);
|
384
|
+
if (ok < 0)
|
385
|
+
goto end;
|
386
|
+
/* Check if we found an alternate chain */
|
387
|
+
if (ok > 0) {
|
388
|
+
/*
|
389
|
+
* Free up the found cert we'll add it again later
|
390
|
+
*/
|
391
|
+
X509_free(xtmp);
|
392
|
+
|
393
|
+
/*
|
394
|
+
* Dump all the certs above this point - we've found an
|
395
|
+
* alternate chain
|
396
|
+
*/
|
397
|
+
while (num > j) {
|
398
|
+
xtmp = sk_X509_pop(ctx->chain);
|
399
|
+
X509_free(xtmp);
|
400
|
+
num--;
|
401
|
+
}
|
402
|
+
ctx->last_untrusted = sk_X509_num(ctx->chain);
|
403
|
+
retry = 1;
|
404
|
+
break;
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
408
|
+
} while (retry);
|
409
|
+
|
410
|
+
/*
|
411
|
+
* If not explicitly trusted then indicate error unless it's a single
|
412
|
+
* self signed certificate in which case we've indicated an error already
|
413
|
+
* and set bad_chain == 1
|
414
|
+
*/
|
415
|
+
if (i != X509_TRUST_TRUSTED && !bad_chain) {
|
416
|
+
if ((chain_ss == NULL) || !ctx->check_issued(ctx, x, chain_ss)) {
|
417
|
+
if (ctx->last_untrusted >= num)
|
418
|
+
ctx->error = X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY;
|
419
|
+
else
|
420
|
+
ctx->error = X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT;
|
421
|
+
ctx->current_cert = x;
|
422
|
+
} else {
|
423
|
+
|
424
|
+
sk_X509_push(ctx->chain, chain_ss);
|
425
|
+
num++;
|
426
|
+
ctx->last_untrusted = num;
|
427
|
+
ctx->current_cert = chain_ss;
|
428
|
+
ctx->error = X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN;
|
429
|
+
chain_ss = NULL;
|
430
|
+
}
|
431
|
+
|
432
|
+
ctx->error_depth = num - 1;
|
433
|
+
bad_chain = 1;
|
434
|
+
ok = cb(0, ctx);
|
435
|
+
if (!ok)
|
436
|
+
goto end;
|
437
|
+
}
|
438
|
+
|
439
|
+
/* We have the chain complete: now we need to check its purpose */
|
440
|
+
ok = check_chain_extensions(ctx);
|
441
|
+
|
442
|
+
if (!ok)
|
443
|
+
goto end;
|
444
|
+
|
445
|
+
/* Check name constraints */
|
446
|
+
|
447
|
+
ok = check_name_constraints(ctx);
|
448
|
+
|
449
|
+
if (!ok)
|
450
|
+
goto end;
|
451
|
+
|
452
|
+
ok = check_id(ctx);
|
453
|
+
|
454
|
+
if (!ok)
|
455
|
+
goto end;
|
456
|
+
|
457
|
+
/*
|
458
|
+
* Check revocation status: we do this after copying parameters because
|
459
|
+
* they may be needed for CRL signature verification.
|
460
|
+
*/
|
461
|
+
|
462
|
+
ok = ctx->check_revocation(ctx);
|
463
|
+
if (!ok)
|
464
|
+
goto end;
|
465
|
+
|
466
|
+
i = X509_chain_check_suiteb(&ctx->error_depth, NULL, ctx->chain,
|
467
|
+
ctx->param->flags);
|
468
|
+
if (i != X509_V_OK) {
|
469
|
+
ctx->error = i;
|
470
|
+
ctx->current_cert = sk_X509_value(ctx->chain, ctx->error_depth);
|
471
|
+
ok = cb(0, ctx);
|
472
|
+
if (!ok)
|
473
|
+
goto end;
|
474
|
+
}
|
475
|
+
|
476
|
+
/* At this point, we have a chain and need to verify it */
|
477
|
+
if (ctx->verify != NULL)
|
478
|
+
ok = ctx->verify(ctx);
|
479
|
+
else
|
480
|
+
ok = internal_verify(ctx);
|
481
|
+
if (!ok)
|
482
|
+
goto end;
|
483
|
+
|
484
|
+
/* If we get this far evaluate policies */
|
485
|
+
if (!bad_chain && (ctx->param->flags & X509_V_FLAG_POLICY_CHECK))
|
486
|
+
ok = ctx->check_policy(ctx);
|
487
|
+
|
488
|
+
end:
|
489
|
+
if (sktmp != NULL)
|
490
|
+
sk_X509_free(sktmp);
|
491
|
+
if (chain_ss != NULL)
|
492
|
+
X509_free(chain_ss);
|
493
|
+
return ok;
|
494
|
+
}
|
495
|
+
|
496
|
+
/*
|
497
|
+
* Given a STACK_OF(X509) find the issuer of cert (if any)
|
456
498
|
*/
|
457
499
|
|
458
500
|
static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x)
|
459
501
|
{
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
return NULL;
|
502
|
+
size_t i;
|
503
|
+
X509 *issuer;
|
504
|
+
for (i = 0; i < sk_X509_num(sk); i++) {
|
505
|
+
issuer = sk_X509_value(sk, i);
|
506
|
+
if (ctx->check_issued(ctx, x, issuer))
|
507
|
+
return issuer;
|
508
|
+
}
|
509
|
+
return NULL;
|
469
510
|
}
|
470
511
|
|
471
512
|
/* Given a possible certificate and issuer check them */
|
472
513
|
|
473
514
|
static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer)
|
474
515
|
{
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
516
|
+
int ret;
|
517
|
+
ret = X509_check_issued(issuer, x);
|
518
|
+
if (ret == X509_V_OK)
|
519
|
+
return 1;
|
520
|
+
/* If we haven't asked for issuer errors don't set ctx */
|
521
|
+
if (!(ctx->param->flags & X509_V_FLAG_CB_ISSUER_CHECK))
|
522
|
+
return 0;
|
523
|
+
|
524
|
+
ctx->error = ret;
|
525
|
+
ctx->current_cert = x;
|
526
|
+
ctx->current_issuer = issuer;
|
527
|
+
return ctx->verify_cb(0, ctx);
|
487
528
|
}
|
488
529
|
|
489
530
|
/* Alternative lookup method: look from a STACK stored in other_ctx */
|
490
531
|
|
491
532
|
static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
|
492
533
|
{
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
else
|
500
|
-
return 0;
|
534
|
+
*issuer = find_issuer(ctx, ctx->other_ctx, x);
|
535
|
+
if (*issuer) {
|
536
|
+
X509_up_ref(*issuer);
|
537
|
+
return 1;
|
538
|
+
} else
|
539
|
+
return 0;
|
501
540
|
}
|
502
|
-
|
503
541
|
|
504
|
-
/*
|
505
|
-
* with the supplied
|
542
|
+
/*
|
543
|
+
* Check a certificate chains extensions for consistency with the supplied
|
544
|
+
* purpose
|
506
545
|
*/
|
507
546
|
|
508
547
|
static int check_chain_extensions(X509_STORE_CTX *ctx)
|
509
548
|
{
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
ctx->error_depth = i;
|
647
|
-
ctx->current_cert = x;
|
648
|
-
ok=cb(0,ctx);
|
649
|
-
if (!ok) goto end;
|
650
|
-
}
|
651
|
-
proxy_path_length++;
|
652
|
-
must_be_ca = 0;
|
653
|
-
}
|
654
|
-
else
|
655
|
-
must_be_ca = 1;
|
656
|
-
}
|
657
|
-
ok = 1;
|
549
|
+
int i, ok = 0, must_be_ca, plen = 0;
|
550
|
+
X509 *x;
|
551
|
+
int (*cb) (int xok, X509_STORE_CTX *xctx);
|
552
|
+
int proxy_path_length = 0;
|
553
|
+
int purpose;
|
554
|
+
int allow_proxy_certs;
|
555
|
+
cb = ctx->verify_cb;
|
556
|
+
|
557
|
+
/*
|
558
|
+
* must_be_ca can have 1 of 3 values: -1: we accept both CA and non-CA
|
559
|
+
* certificates, to allow direct use of self-signed certificates (which
|
560
|
+
* are marked as CA). 0: we only accept non-CA certificates. This is
|
561
|
+
* currently not used, but the possibility is present for future
|
562
|
+
* extensions. 1: we only accept CA certificates. This is currently used
|
563
|
+
* for all certificates in the chain except the leaf certificate.
|
564
|
+
*/
|
565
|
+
must_be_ca = -1;
|
566
|
+
|
567
|
+
/* CRL path validation */
|
568
|
+
if (ctx->parent) {
|
569
|
+
allow_proxy_certs = 0;
|
570
|
+
purpose = X509_PURPOSE_CRL_SIGN;
|
571
|
+
} else {
|
572
|
+
allow_proxy_certs =
|
573
|
+
! !(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS);
|
574
|
+
/*
|
575
|
+
* A hack to keep people who don't want to modify their software
|
576
|
+
* happy
|
577
|
+
*/
|
578
|
+
if (getenv("OPENSSL_ALLOW_PROXY_CERTS"))
|
579
|
+
allow_proxy_certs = 1;
|
580
|
+
purpose = ctx->param->purpose;
|
581
|
+
}
|
582
|
+
|
583
|
+
/* Check all untrusted certificates */
|
584
|
+
for (i = 0; i < ctx->last_untrusted; i++) {
|
585
|
+
int ret;
|
586
|
+
x = sk_X509_value(ctx->chain, i);
|
587
|
+
if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
|
588
|
+
&& (x->ex_flags & EXFLAG_CRITICAL)) {
|
589
|
+
ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION;
|
590
|
+
ctx->error_depth = i;
|
591
|
+
ctx->current_cert = x;
|
592
|
+
ok = cb(0, ctx);
|
593
|
+
if (!ok)
|
594
|
+
goto end;
|
595
|
+
}
|
596
|
+
if (!allow_proxy_certs && (x->ex_flags & EXFLAG_PROXY)) {
|
597
|
+
ctx->error = X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED;
|
598
|
+
ctx->error_depth = i;
|
599
|
+
ctx->current_cert = x;
|
600
|
+
ok = cb(0, ctx);
|
601
|
+
if (!ok)
|
602
|
+
goto end;
|
603
|
+
}
|
604
|
+
ret = X509_check_ca(x);
|
605
|
+
switch (must_be_ca) {
|
606
|
+
case -1:
|
607
|
+
if ((ctx->param->flags & X509_V_FLAG_X509_STRICT)
|
608
|
+
&& (ret != 1) && (ret != 0)) {
|
609
|
+
ret = 0;
|
610
|
+
ctx->error = X509_V_ERR_INVALID_CA;
|
611
|
+
} else
|
612
|
+
ret = 1;
|
613
|
+
break;
|
614
|
+
case 0:
|
615
|
+
if (ret != 0) {
|
616
|
+
ret = 0;
|
617
|
+
ctx->error = X509_V_ERR_INVALID_NON_CA;
|
618
|
+
} else
|
619
|
+
ret = 1;
|
620
|
+
break;
|
621
|
+
default:
|
622
|
+
if ((ret == 0)
|
623
|
+
|| ((ctx->param->flags & X509_V_FLAG_X509_STRICT)
|
624
|
+
&& (ret != 1))) {
|
625
|
+
ret = 0;
|
626
|
+
ctx->error = X509_V_ERR_INVALID_CA;
|
627
|
+
} else
|
628
|
+
ret = 1;
|
629
|
+
break;
|
630
|
+
}
|
631
|
+
if (ret == 0) {
|
632
|
+
ctx->error_depth = i;
|
633
|
+
ctx->current_cert = x;
|
634
|
+
ok = cb(0, ctx);
|
635
|
+
if (!ok)
|
636
|
+
goto end;
|
637
|
+
}
|
638
|
+
if (ctx->param->purpose > 0) {
|
639
|
+
ret = X509_check_purpose(x, purpose, must_be_ca > 0);
|
640
|
+
if ((ret == 0)
|
641
|
+
|| ((ctx->param->flags & X509_V_FLAG_X509_STRICT)
|
642
|
+
&& (ret != 1))) {
|
643
|
+
ctx->error = X509_V_ERR_INVALID_PURPOSE;
|
644
|
+
ctx->error_depth = i;
|
645
|
+
ctx->current_cert = x;
|
646
|
+
ok = cb(0, ctx);
|
647
|
+
if (!ok)
|
648
|
+
goto end;
|
649
|
+
}
|
650
|
+
}
|
651
|
+
/* Check pathlen if not self issued */
|
652
|
+
if ((i > 1) && !(x->ex_flags & EXFLAG_SI)
|
653
|
+
&& (x->ex_pathlen != -1)
|
654
|
+
&& (plen > (x->ex_pathlen + proxy_path_length + 1))) {
|
655
|
+
ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED;
|
656
|
+
ctx->error_depth = i;
|
657
|
+
ctx->current_cert = x;
|
658
|
+
ok = cb(0, ctx);
|
659
|
+
if (!ok)
|
660
|
+
goto end;
|
661
|
+
}
|
662
|
+
/* Increment path length if not self issued */
|
663
|
+
if (!(x->ex_flags & EXFLAG_SI))
|
664
|
+
plen++;
|
665
|
+
/*
|
666
|
+
* If this certificate is a proxy certificate, the next certificate
|
667
|
+
* must be another proxy certificate or a EE certificate. If not,
|
668
|
+
* the next certificate must be a CA certificate.
|
669
|
+
*/
|
670
|
+
if (x->ex_flags & EXFLAG_PROXY) {
|
671
|
+
if (x->ex_pcpathlen != -1 && i > x->ex_pcpathlen) {
|
672
|
+
ctx->error = X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED;
|
673
|
+
ctx->error_depth = i;
|
674
|
+
ctx->current_cert = x;
|
675
|
+
ok = cb(0, ctx);
|
676
|
+
if (!ok)
|
677
|
+
goto end;
|
678
|
+
}
|
679
|
+
proxy_path_length++;
|
680
|
+
must_be_ca = 0;
|
681
|
+
} else
|
682
|
+
must_be_ca = 1;
|
683
|
+
}
|
684
|
+
ok = 1;
|
658
685
|
end:
|
659
|
-
|
686
|
+
return ok;
|
660
687
|
}
|
661
688
|
|
662
689
|
static int check_name_constraints(X509_STORE_CTX *ctx)
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
}
|
695
|
-
return 1;
|
696
|
-
}
|
690
|
+
{
|
691
|
+
X509 *x;
|
692
|
+
int i, j, rv;
|
693
|
+
/* Check name constraints for all certificates */
|
694
|
+
for (i = sk_X509_num(ctx->chain) - 1; i >= 0; i--) {
|
695
|
+
x = sk_X509_value(ctx->chain, i);
|
696
|
+
/* Ignore self issued certs unless last in chain */
|
697
|
+
if (i && (x->ex_flags & EXFLAG_SI))
|
698
|
+
continue;
|
699
|
+
/*
|
700
|
+
* Check against constraints for all certificates higher in chain
|
701
|
+
* including trust anchor. Trust anchor not strictly speaking needed
|
702
|
+
* but if it includes constraints it is to be assumed it expects them
|
703
|
+
* to be obeyed.
|
704
|
+
*/
|
705
|
+
for (j = sk_X509_num(ctx->chain) - 1; j > i; j--) {
|
706
|
+
NAME_CONSTRAINTS *nc = sk_X509_value(ctx->chain, j)->nc;
|
707
|
+
if (nc) {
|
708
|
+
rv = NAME_CONSTRAINTS_check(x, nc);
|
709
|
+
if (rv != X509_V_OK) {
|
710
|
+
ctx->error = rv;
|
711
|
+
ctx->error_depth = i;
|
712
|
+
ctx->current_cert = x;
|
713
|
+
if (!ctx->verify_cb(0, ctx))
|
714
|
+
return 0;
|
715
|
+
}
|
716
|
+
}
|
717
|
+
}
|
718
|
+
}
|
719
|
+
return 1;
|
720
|
+
}
|
697
721
|
|
698
722
|
static int check_id_error(X509_STORE_CTX *ctx, int errcode)
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
723
|
+
{
|
724
|
+
ctx->error = errcode;
|
725
|
+
ctx->current_cert = ctx->cert;
|
726
|
+
ctx->error_depth = 0;
|
727
|
+
return ctx->verify_cb(0, ctx);
|
728
|
+
}
|
705
729
|
|
706
730
|
static int check_hosts(X509 *x, X509_VERIFY_PARAM_ID *id)
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
731
|
+
{
|
732
|
+
size_t i;
|
733
|
+
size_t n = sk_OPENSSL_STRING_num(id->hosts);
|
734
|
+
char *name;
|
735
|
+
|
736
|
+
if (id->peername != NULL) {
|
737
|
+
OPENSSL_free(id->peername);
|
738
|
+
id->peername = NULL;
|
739
|
+
}
|
740
|
+
for (i = 0; i < n; ++i) {
|
741
|
+
name = sk_OPENSSL_STRING_value(id->hosts, i);
|
742
|
+
if (X509_check_host(x, name, strlen(name), id->hostflags,
|
743
|
+
&id->peername) > 0)
|
744
|
+
return 1;
|
745
|
+
}
|
746
|
+
return n == 0;
|
747
|
+
}
|
721
748
|
|
722
749
|
static int check_id(X509_STORE_CTX *ctx)
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
}
|
742
|
-
return 1;
|
743
|
-
}
|
750
|
+
{
|
751
|
+
X509_VERIFY_PARAM *vpm = ctx->param;
|
752
|
+
X509_VERIFY_PARAM_ID *id = vpm->id;
|
753
|
+
X509 *x = ctx->cert;
|
754
|
+
if (id->hosts && check_hosts(x, id) <= 0) {
|
755
|
+
if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH))
|
756
|
+
return 0;
|
757
|
+
}
|
758
|
+
if (id->email && X509_check_email(x, id->email, id->emaillen, 0) <= 0) {
|
759
|
+
if (!check_id_error(ctx, X509_V_ERR_EMAIL_MISMATCH))
|
760
|
+
return 0;
|
761
|
+
}
|
762
|
+
if (id->ip && X509_check_ip(x, id->ip, id->iplen, 0) <= 0) {
|
763
|
+
if (!check_id_error(ctx, X509_V_ERR_IP_ADDRESS_MISMATCH))
|
764
|
+
return 0;
|
765
|
+
}
|
766
|
+
return 1;
|
767
|
+
}
|
744
768
|
|
745
769
|
static int check_trust(X509_STORE_CTX *ctx)
|
746
770
|
{
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
return X509_TRUST_UNTRUSTED;
|
771
|
+
size_t i;
|
772
|
+
int ok;
|
773
|
+
X509 *x = NULL;
|
774
|
+
int (*cb) (int xok, X509_STORE_CTX *xctx);
|
775
|
+
cb = ctx->verify_cb;
|
776
|
+
/* Check all trusted certificates in chain */
|
777
|
+
for (i = ctx->last_untrusted; i < sk_X509_num(ctx->chain); i++) {
|
778
|
+
x = sk_X509_value(ctx->chain, i);
|
779
|
+
ok = X509_check_trust(x, ctx->param->trust, 0);
|
780
|
+
/* If explicitly trusted return trusted */
|
781
|
+
if (ok == X509_TRUST_TRUSTED)
|
782
|
+
return X509_TRUST_TRUSTED;
|
783
|
+
/*
|
784
|
+
* If explicitly rejected notify callback and reject if not
|
785
|
+
* overridden.
|
786
|
+
*/
|
787
|
+
if (ok == X509_TRUST_REJECTED) {
|
788
|
+
ctx->error_depth = i;
|
789
|
+
ctx->current_cert = x;
|
790
|
+
ctx->error = X509_V_ERR_CERT_REJECTED;
|
791
|
+
ok = cb(0, ctx);
|
792
|
+
if (!ok)
|
793
|
+
return X509_TRUST_REJECTED;
|
794
|
+
}
|
795
|
+
}
|
796
|
+
/*
|
797
|
+
* If we accept partial chains and have at least one trusted certificate
|
798
|
+
* return success.
|
799
|
+
*/
|
800
|
+
if (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) {
|
801
|
+
X509 *mx;
|
802
|
+
if (ctx->last_untrusted < (int)sk_X509_num(ctx->chain))
|
803
|
+
return X509_TRUST_TRUSTED;
|
804
|
+
x = sk_X509_value(ctx->chain, 0);
|
805
|
+
mx = lookup_cert_match(ctx, x);
|
806
|
+
if (mx) {
|
807
|
+
(void)sk_X509_set(ctx->chain, 0, mx);
|
808
|
+
X509_free(x);
|
809
|
+
ctx->last_untrusted = 0;
|
810
|
+
return X509_TRUST_TRUSTED;
|
811
|
+
}
|
812
|
+
}
|
813
|
+
|
814
|
+
/*
|
815
|
+
* If no trusted certs in chain at all return untrusted and allow
|
816
|
+
* standard (no issuer cert) etc errors to be indicated.
|
817
|
+
*/
|
818
|
+
return X509_TRUST_UNTRUSTED;
|
796
819
|
}
|
797
820
|
|
798
821
|
static int check_revocation(X509_STORE_CTX *ctx)
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
}
|
822
|
+
{
|
823
|
+
int i, last, ok;
|
824
|
+
if (!(ctx->param->flags & X509_V_FLAG_CRL_CHECK))
|
825
|
+
return 1;
|
826
|
+
if (ctx->param->flags & X509_V_FLAG_CRL_CHECK_ALL)
|
827
|
+
last = sk_X509_num(ctx->chain) - 1;
|
828
|
+
else {
|
829
|
+
/* If checking CRL paths this isn't the EE certificate */
|
830
|
+
if (ctx->parent)
|
831
|
+
return 1;
|
832
|
+
last = 0;
|
833
|
+
}
|
834
|
+
for (i = 0; i <= last; i++) {
|
835
|
+
ctx->error_depth = i;
|
836
|
+
ok = check_cert(ctx);
|
837
|
+
if (!ok)
|
838
|
+
return ok;
|
839
|
+
}
|
840
|
+
return 1;
|
841
|
+
}
|
820
842
|
|
821
843
|
static int check_cert(X509_STORE_CTX *ctx)
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
ctx->current_crl = NULL;
|
895
|
-
return ok;
|
896
|
-
|
897
|
-
}
|
844
|
+
OPENSSL_SUPPRESS_POTENTIALLY_UNINITIALIZED_WARNINGS
|
845
|
+
{
|
846
|
+
X509_CRL *crl = NULL, *dcrl = NULL;
|
847
|
+
X509 *x;
|
848
|
+
int ok, cnum;
|
849
|
+
unsigned int last_reasons;
|
850
|
+
cnum = ctx->error_depth;
|
851
|
+
x = sk_X509_value(ctx->chain, cnum);
|
852
|
+
ctx->current_cert = x;
|
853
|
+
ctx->current_issuer = NULL;
|
854
|
+
ctx->current_crl_score = 0;
|
855
|
+
ctx->current_reasons = 0;
|
856
|
+
while (ctx->current_reasons != CRLDP_ALL_REASONS) {
|
857
|
+
last_reasons = ctx->current_reasons;
|
858
|
+
/* Try to retrieve relevant CRL */
|
859
|
+
if (ctx->get_crl)
|
860
|
+
ok = ctx->get_crl(ctx, &crl, x);
|
861
|
+
else
|
862
|
+
ok = get_crl_delta(ctx, &crl, &dcrl, x);
|
863
|
+
/*
|
864
|
+
* If error looking up CRL, nothing we can do except notify callback
|
865
|
+
*/
|
866
|
+
if (!ok) {
|
867
|
+
ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
|
868
|
+
ok = ctx->verify_cb(0, ctx);
|
869
|
+
goto err;
|
870
|
+
}
|
871
|
+
ctx->current_crl = crl;
|
872
|
+
ok = ctx->check_crl(ctx, crl);
|
873
|
+
if (!ok)
|
874
|
+
goto err;
|
875
|
+
|
876
|
+
if (dcrl) {
|
877
|
+
ok = ctx->check_crl(ctx, dcrl);
|
878
|
+
if (!ok)
|
879
|
+
goto err;
|
880
|
+
ok = ctx->cert_crl(ctx, dcrl, x);
|
881
|
+
if (!ok)
|
882
|
+
goto err;
|
883
|
+
} else
|
884
|
+
ok = 1;
|
885
|
+
|
886
|
+
/* Don't look in full CRL if delta reason is removefromCRL */
|
887
|
+
if (ok != 2) {
|
888
|
+
ok = ctx->cert_crl(ctx, crl, x);
|
889
|
+
if (!ok)
|
890
|
+
goto err;
|
891
|
+
}
|
892
|
+
|
893
|
+
X509_CRL_free(crl);
|
894
|
+
X509_CRL_free(dcrl);
|
895
|
+
crl = NULL;
|
896
|
+
dcrl = NULL;
|
897
|
+
/*
|
898
|
+
* If reasons not updated we wont get anywhere by another iteration,
|
899
|
+
* so exit loop.
|
900
|
+
*/
|
901
|
+
if (last_reasons == ctx->current_reasons) {
|
902
|
+
ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
|
903
|
+
ok = ctx->verify_cb(0, ctx);
|
904
|
+
goto err;
|
905
|
+
}
|
906
|
+
}
|
907
|
+
err:
|
908
|
+
X509_CRL_free(crl);
|
909
|
+
X509_CRL_free(dcrl);
|
910
|
+
|
911
|
+
ctx->current_crl = NULL;
|
912
|
+
return ok;
|
913
|
+
|
914
|
+
}
|
898
915
|
|
899
916
|
/* Check CRL times against values in X509_STORE_CTX */
|
900
917
|
|
901
918
|
static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
if (notify)
|
955
|
-
ctx->current_crl = NULL;
|
956
|
-
|
957
|
-
return 1;
|
958
|
-
}
|
919
|
+
{
|
920
|
+
time_t *ptime;
|
921
|
+
int i;
|
922
|
+
if (notify)
|
923
|
+
ctx->current_crl = crl;
|
924
|
+
if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
|
925
|
+
ptime = &ctx->param->check_time;
|
926
|
+
else
|
927
|
+
ptime = NULL;
|
928
|
+
|
929
|
+
i = X509_cmp_time(X509_CRL_get_lastUpdate(crl), ptime);
|
930
|
+
if (i == 0) {
|
931
|
+
if (!notify)
|
932
|
+
return 0;
|
933
|
+
ctx->error = X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD;
|
934
|
+
if (!ctx->verify_cb(0, ctx))
|
935
|
+
return 0;
|
936
|
+
}
|
937
|
+
|
938
|
+
if (i > 0) {
|
939
|
+
if (!notify)
|
940
|
+
return 0;
|
941
|
+
ctx->error = X509_V_ERR_CRL_NOT_YET_VALID;
|
942
|
+
if (!ctx->verify_cb(0, ctx))
|
943
|
+
return 0;
|
944
|
+
}
|
945
|
+
|
946
|
+
if (X509_CRL_get_nextUpdate(crl)) {
|
947
|
+
i = X509_cmp_time(X509_CRL_get_nextUpdate(crl), ptime);
|
948
|
+
|
949
|
+
if (i == 0) {
|
950
|
+
if (!notify)
|
951
|
+
return 0;
|
952
|
+
ctx->error = X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD;
|
953
|
+
if (!ctx->verify_cb(0, ctx))
|
954
|
+
return 0;
|
955
|
+
}
|
956
|
+
/* Ignore expiry of base CRL is delta is valid */
|
957
|
+
if ((i < 0) && !(ctx->current_crl_score & CRL_SCORE_TIME_DELTA)) {
|
958
|
+
if (!notify)
|
959
|
+
return 0;
|
960
|
+
ctx->error = X509_V_ERR_CRL_HAS_EXPIRED;
|
961
|
+
if (!ctx->verify_cb(0, ctx))
|
962
|
+
return 0;
|
963
|
+
}
|
964
|
+
}
|
965
|
+
|
966
|
+
if (notify)
|
967
|
+
ctx->current_crl = NULL;
|
968
|
+
|
969
|
+
return 1;
|
970
|
+
}
|
959
971
|
|
960
972
|
static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl,
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
}
|
1008
|
-
|
1009
|
-
/* Compare two CRL extensions for delta checking purposes. They should be
|
973
|
+
X509 **pissuer, int *pscore, unsigned int *preasons,
|
974
|
+
STACK_OF(X509_CRL) *crls)
|
975
|
+
{
|
976
|
+
int crl_score, best_score = *pscore;
|
977
|
+
size_t i;
|
978
|
+
unsigned int reasons, best_reasons = 0;
|
979
|
+
X509 *x = ctx->current_cert;
|
980
|
+
X509_CRL *crl, *best_crl = NULL;
|
981
|
+
X509 *crl_issuer = NULL, *best_crl_issuer = NULL;
|
982
|
+
|
983
|
+
for (i = 0; i < sk_X509_CRL_num(crls); i++) {
|
984
|
+
crl = sk_X509_CRL_value(crls, i);
|
985
|
+
reasons = *preasons;
|
986
|
+
crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x);
|
987
|
+
|
988
|
+
if (crl_score > best_score) {
|
989
|
+
best_crl = crl;
|
990
|
+
best_crl_issuer = crl_issuer;
|
991
|
+
best_score = crl_score;
|
992
|
+
best_reasons = reasons;
|
993
|
+
}
|
994
|
+
}
|
995
|
+
|
996
|
+
if (best_crl) {
|
997
|
+
if (*pcrl)
|
998
|
+
X509_CRL_free(*pcrl);
|
999
|
+
*pcrl = best_crl;
|
1000
|
+
*pissuer = best_crl_issuer;
|
1001
|
+
*pscore = best_score;
|
1002
|
+
*preasons = best_reasons;
|
1003
|
+
X509_CRL_up_ref(best_crl);
|
1004
|
+
if (*pdcrl) {
|
1005
|
+
X509_CRL_free(*pdcrl);
|
1006
|
+
*pdcrl = NULL;
|
1007
|
+
}
|
1008
|
+
get_delta_sk(ctx, pdcrl, pscore, best_crl, crls);
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
if (best_score >= CRL_SCORE_VALID)
|
1012
|
+
return 1;
|
1013
|
+
|
1014
|
+
return 0;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
/*
|
1018
|
+
* Compare two CRL extensions for delta checking purposes. They should be
|
1010
1019
|
* both present or both absent. If both present all fields must be identical.
|
1011
1020
|
*/
|
1012
1021
|
|
1013
1022
|
static int crl_extension_match(X509_CRL *a, X509_CRL *b, int nid)
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
else
|
1026
|
-
exta = NULL;
|
1027
|
-
|
1028
|
-
i = X509_CRL_get_ext_by_NID(b, nid, -1);
|
1023
|
+
{
|
1024
|
+
ASN1_OCTET_STRING *exta, *extb;
|
1025
|
+
int i;
|
1026
|
+
i = X509_CRL_get_ext_by_NID(a, nid, -1);
|
1027
|
+
if (i >= 0) {
|
1028
|
+
/* Can't have multiple occurrences */
|
1029
|
+
if (X509_CRL_get_ext_by_NID(a, nid, i) != -1)
|
1030
|
+
return 0;
|
1031
|
+
exta = X509_EXTENSION_get_data(X509_CRL_get_ext(a, i));
|
1032
|
+
} else
|
1033
|
+
exta = NULL;
|
1029
1034
|
|
1030
|
-
|
1031
|
-
{
|
1035
|
+
i = X509_CRL_get_ext_by_NID(b, nid, -1);
|
1032
1036
|
|
1033
|
-
|
1034
|
-
return 0;
|
1035
|
-
extb = X509_EXTENSION_get_data(X509_CRL_get_ext(b, i));
|
1036
|
-
}
|
1037
|
-
else
|
1038
|
-
extb = NULL;
|
1037
|
+
if (i >= 0) {
|
1039
1038
|
|
1040
|
-
|
1041
|
-
|
1039
|
+
if (X509_CRL_get_ext_by_NID(b, nid, i) != -1)
|
1040
|
+
return 0;
|
1041
|
+
extb = X509_EXTENSION_get_data(X509_CRL_get_ext(b, i));
|
1042
|
+
} else
|
1043
|
+
extb = NULL;
|
1042
1044
|
|
1043
|
-
|
1044
|
-
|
1045
|
+
if (!exta && !extb)
|
1046
|
+
return 1;
|
1045
1047
|
|
1048
|
+
if (!exta || !extb)
|
1049
|
+
return 0;
|
1046
1050
|
|
1047
|
-
|
1048
|
-
|
1051
|
+
if (ASN1_OCTET_STRING_cmp(exta, extb))
|
1052
|
+
return 0;
|
1049
1053
|
|
1050
|
-
|
1051
|
-
|
1054
|
+
return 1;
|
1055
|
+
}
|
1052
1056
|
|
1053
1057
|
/* See if a base and delta are compatible */
|
1054
1058
|
|
1055
1059
|
static int check_delta_base(X509_CRL *delta, X509_CRL *base)
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
*
|
1060
|
+
{
|
1061
|
+
/* Delta CRL must be a delta */
|
1062
|
+
if (!delta->base_crl_number)
|
1063
|
+
return 0;
|
1064
|
+
/* Base must have a CRL number */
|
1065
|
+
if (!base->crl_number)
|
1066
|
+
return 0;
|
1067
|
+
/* Issuer names must match */
|
1068
|
+
if (X509_NAME_cmp(X509_CRL_get_issuer(base), X509_CRL_get_issuer(delta)))
|
1069
|
+
return 0;
|
1070
|
+
/* AKID and IDP must match */
|
1071
|
+
if (!crl_extension_match(delta, base, NID_authority_key_identifier))
|
1072
|
+
return 0;
|
1073
|
+
if (!crl_extension_match(delta, base, NID_issuing_distribution_point))
|
1074
|
+
return 0;
|
1075
|
+
/* Delta CRL base number must not exceed Full CRL number. */
|
1076
|
+
if (ASN1_INTEGER_cmp(delta->base_crl_number, base->crl_number) > 0)
|
1077
|
+
return 0;
|
1078
|
+
/* Delta CRL number must exceed full CRL number */
|
1079
|
+
if (ASN1_INTEGER_cmp(delta->crl_number, base->crl_number) > 0)
|
1080
|
+
return 1;
|
1081
|
+
return 0;
|
1082
|
+
}
|
1083
|
+
|
1084
|
+
/*
|
1085
|
+
* For a given base CRL find a delta... maybe extend to delta scoring or
|
1086
|
+
* retrieve a chain of deltas...
|
1083
1087
|
*/
|
1084
1088
|
|
1085
1089
|
static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pscore,
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
*
|
1111
|
-
*
|
1112
|
-
*
|
1113
|
-
* no new reasons the CRL is rejected, otherwise reasons is updated.
|
1090
|
+
X509_CRL *base, STACK_OF(X509_CRL) *crls)
|
1091
|
+
{
|
1092
|
+
X509_CRL *delta;
|
1093
|
+
size_t i;
|
1094
|
+
if (!(ctx->param->flags & X509_V_FLAG_USE_DELTAS))
|
1095
|
+
return;
|
1096
|
+
if (!((ctx->current_cert->ex_flags | base->flags) & EXFLAG_FRESHEST))
|
1097
|
+
return;
|
1098
|
+
for (i = 0; i < sk_X509_CRL_num(crls); i++) {
|
1099
|
+
delta = sk_X509_CRL_value(crls, i);
|
1100
|
+
if (check_delta_base(delta, base)) {
|
1101
|
+
if (check_crl_time(ctx, delta, 0))
|
1102
|
+
*pscore |= CRL_SCORE_TIME_DELTA;
|
1103
|
+
X509_CRL_up_ref(delta);
|
1104
|
+
*dcrl = delta;
|
1105
|
+
return;
|
1106
|
+
}
|
1107
|
+
}
|
1108
|
+
*dcrl = NULL;
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
/*
|
1112
|
+
* For a given CRL return how suitable it is for the supplied certificate
|
1113
|
+
* 'x'. The return value is a mask of several criteria. If the issuer is not
|
1114
|
+
* the certificate issuer this is returned in *pissuer. The reasons mask is
|
1115
|
+
* also used to determine if the CRL is suitable: if no new reasons the CRL
|
1116
|
+
* is rejected, otherwise reasons is updated.
|
1114
1117
|
*/
|
1115
1118
|
|
1116
1119
|
static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
}
|
1178
|
-
|
1179
|
-
*preasons = tmp_reasons;
|
1180
|
-
|
1181
|
-
return crl_score;
|
1182
|
-
|
1183
|
-
}
|
1120
|
+
unsigned int *preasons, X509_CRL *crl, X509 *x)
|
1121
|
+
{
|
1122
|
+
|
1123
|
+
int crl_score = 0;
|
1124
|
+
unsigned int tmp_reasons = *preasons, crl_reasons;
|
1125
|
+
|
1126
|
+
/* First see if we can reject CRL straight away */
|
1127
|
+
|
1128
|
+
/* Invalid IDP cannot be processed */
|
1129
|
+
if (crl->idp_flags & IDP_INVALID)
|
1130
|
+
return 0;
|
1131
|
+
/* Reason codes or indirect CRLs need extended CRL support */
|
1132
|
+
if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT)) {
|
1133
|
+
if (crl->idp_flags & (IDP_INDIRECT | IDP_REASONS))
|
1134
|
+
return 0;
|
1135
|
+
} else if (crl->idp_flags & IDP_REASONS) {
|
1136
|
+
/* If no new reasons reject */
|
1137
|
+
if (!(crl->idp_reasons & ~tmp_reasons))
|
1138
|
+
return 0;
|
1139
|
+
}
|
1140
|
+
/* Don't process deltas at this stage */
|
1141
|
+
else if (crl->base_crl_number)
|
1142
|
+
return 0;
|
1143
|
+
/* If issuer name doesn't match certificate need indirect CRL */
|
1144
|
+
if (X509_NAME_cmp(X509_get_issuer_name(x), X509_CRL_get_issuer(crl))) {
|
1145
|
+
if (!(crl->idp_flags & IDP_INDIRECT))
|
1146
|
+
return 0;
|
1147
|
+
} else
|
1148
|
+
crl_score |= CRL_SCORE_ISSUER_NAME;
|
1149
|
+
|
1150
|
+
if (!(crl->flags & EXFLAG_CRITICAL))
|
1151
|
+
crl_score |= CRL_SCORE_NOCRITICAL;
|
1152
|
+
|
1153
|
+
/* Check expiry */
|
1154
|
+
if (check_crl_time(ctx, crl, 0))
|
1155
|
+
crl_score |= CRL_SCORE_TIME;
|
1156
|
+
|
1157
|
+
/* Check authority key ID and locate certificate issuer */
|
1158
|
+
crl_akid_check(ctx, crl, pissuer, &crl_score);
|
1159
|
+
|
1160
|
+
/* If we can't locate certificate issuer at this point forget it */
|
1161
|
+
|
1162
|
+
if (!(crl_score & CRL_SCORE_AKID))
|
1163
|
+
return 0;
|
1164
|
+
|
1165
|
+
/* Check cert for matching CRL distribution points */
|
1166
|
+
|
1167
|
+
if (crl_crldp_check(x, crl, crl_score, &crl_reasons)) {
|
1168
|
+
/* If no new reasons reject */
|
1169
|
+
if (!(crl_reasons & ~tmp_reasons))
|
1170
|
+
return 0;
|
1171
|
+
tmp_reasons |= crl_reasons;
|
1172
|
+
crl_score |= CRL_SCORE_SCOPE;
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
*preasons = tmp_reasons;
|
1176
|
+
|
1177
|
+
return crl_score;
|
1178
|
+
|
1179
|
+
}
|
1184
1180
|
|
1185
1181
|
static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
}
|
1241
|
-
}
|
1242
|
-
|
1243
|
-
/* Check the path of a CRL issuer certificate. This creates a new
|
1182
|
+
X509 **pissuer, int *pcrl_score)
|
1183
|
+
{
|
1184
|
+
X509 *crl_issuer = NULL;
|
1185
|
+
X509_NAME *cnm = X509_CRL_get_issuer(crl);
|
1186
|
+
int cidx = ctx->error_depth;
|
1187
|
+
size_t i;
|
1188
|
+
|
1189
|
+
if ((size_t)cidx != sk_X509_num(ctx->chain) - 1)
|
1190
|
+
cidx++;
|
1191
|
+
|
1192
|
+
crl_issuer = sk_X509_value(ctx->chain, cidx);
|
1193
|
+
|
1194
|
+
if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
|
1195
|
+
if (*pcrl_score & CRL_SCORE_ISSUER_NAME) {
|
1196
|
+
*pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_ISSUER_CERT;
|
1197
|
+
*pissuer = crl_issuer;
|
1198
|
+
return;
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
|
1202
|
+
for (cidx++; cidx < (int)sk_X509_num(ctx->chain); cidx++) {
|
1203
|
+
crl_issuer = sk_X509_value(ctx->chain, cidx);
|
1204
|
+
if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
|
1205
|
+
continue;
|
1206
|
+
if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
|
1207
|
+
*pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_SAME_PATH;
|
1208
|
+
*pissuer = crl_issuer;
|
1209
|
+
return;
|
1210
|
+
}
|
1211
|
+
}
|
1212
|
+
|
1213
|
+
/* Anything else needs extended CRL support */
|
1214
|
+
|
1215
|
+
if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT))
|
1216
|
+
return;
|
1217
|
+
|
1218
|
+
/*
|
1219
|
+
* Otherwise the CRL issuer is not on the path. Look for it in the set of
|
1220
|
+
* untrusted certificates.
|
1221
|
+
*/
|
1222
|
+
for (i = 0; i < sk_X509_num(ctx->untrusted); i++) {
|
1223
|
+
crl_issuer = sk_X509_value(ctx->untrusted, i);
|
1224
|
+
if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
|
1225
|
+
continue;
|
1226
|
+
if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
|
1227
|
+
*pissuer = crl_issuer;
|
1228
|
+
*pcrl_score |= CRL_SCORE_AKID;
|
1229
|
+
return;
|
1230
|
+
}
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
/*
|
1235
|
+
* Check the path of a CRL issuer certificate. This creates a new
|
1244
1236
|
* X509_STORE_CTX and populates it with most of the parameters from the
|
1245
|
-
* parent. This could be optimised somewhat since a lot of path checking
|
1246
|
-
*
|
1247
|
-
* practice.
|
1237
|
+
* parent. This could be optimised somewhat since a lot of path checking will
|
1238
|
+
* be duplicated by the parent, but this will rarely be used in practice.
|
1248
1239
|
*/
|
1249
1240
|
|
1250
1241
|
static int check_crl_path(X509_STORE_CTX *ctx, X509 *x)
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
/*
|
1282
|
-
*
|
1283
|
-
* certificate could
|
1284
|
-
*
|
1285
|
-
* end in the same trust anchor,
|
1286
|
-
* until this is resolved we use the
|
1242
|
+
{
|
1243
|
+
X509_STORE_CTX crl_ctx;
|
1244
|
+
int ret;
|
1245
|
+
/* Don't allow recursive CRL path validation */
|
1246
|
+
if (ctx->parent)
|
1247
|
+
return 0;
|
1248
|
+
if (!X509_STORE_CTX_init(&crl_ctx, ctx->ctx, x, ctx->untrusted))
|
1249
|
+
return -1;
|
1250
|
+
|
1251
|
+
crl_ctx.crls = ctx->crls;
|
1252
|
+
/* Copy verify params across */
|
1253
|
+
X509_STORE_CTX_set0_param(&crl_ctx, ctx->param);
|
1254
|
+
|
1255
|
+
crl_ctx.parent = ctx;
|
1256
|
+
crl_ctx.verify_cb = ctx->verify_cb;
|
1257
|
+
|
1258
|
+
/* Verify CRL issuer */
|
1259
|
+
ret = X509_verify_cert(&crl_ctx);
|
1260
|
+
|
1261
|
+
if (ret <= 0)
|
1262
|
+
goto err;
|
1263
|
+
|
1264
|
+
/* Check chain is acceptable */
|
1265
|
+
|
1266
|
+
ret = check_crl_chain(ctx, ctx->chain, crl_ctx.chain);
|
1267
|
+
err:
|
1268
|
+
X509_STORE_CTX_cleanup(&crl_ctx);
|
1269
|
+
return ret;
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
/*
|
1273
|
+
* RFC3280 says nothing about the relationship between CRL path and
|
1274
|
+
* certificate path, which could lead to situations where a certificate could
|
1275
|
+
* be revoked or validated by a CA not authorised to do so. RFC5280 is more
|
1276
|
+
* strict and states that the two paths must end in the same trust anchor,
|
1277
|
+
* though some discussions remain... until this is resolved we use the
|
1278
|
+
* RFC5280 version
|
1287
1279
|
*/
|
1288
1280
|
|
1289
1281
|
static int check_crl_chain(X509_STORE_CTX *ctx,
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
/* Check for match between two dist point names: three separate cases.
|
1302
|
-
* 1. Both are relative names and compare X509_NAME types.
|
1303
|
-
* 2. One full, one relative. Compare X509_NAME to GENERAL_NAMES.
|
1304
|
-
* 3. Both are full names and compare two GENERAL_NAMES.
|
1305
|
-
* 4. One is NULL: automatic match.
|
1306
|
-
*/
|
1282
|
+
STACK_OF(X509) *cert_path,
|
1283
|
+
STACK_OF(X509) *crl_path)
|
1284
|
+
{
|
1285
|
+
X509 *cert_ta, *crl_ta;
|
1286
|
+
cert_ta = sk_X509_value(cert_path, sk_X509_num(cert_path) - 1);
|
1287
|
+
crl_ta = sk_X509_value(crl_path, sk_X509_num(crl_path) - 1);
|
1288
|
+
if (!X509_cmp(cert_ta, crl_ta))
|
1289
|
+
return 1;
|
1290
|
+
return 0;
|
1291
|
+
}
|
1307
1292
|
|
1293
|
+
/*
|
1294
|
+
* Check for match between two dist point names: three separate cases. 1.
|
1295
|
+
* Both are relative names and compare X509_NAME types. 2. One full, one
|
1296
|
+
* relative. Compare X509_NAME to GENERAL_NAMES. 3. Both are full names and
|
1297
|
+
* compare two GENERAL_NAMES. 4. One is NULL: automatic match.
|
1298
|
+
*/
|
1308
1299
|
|
1309
1300
|
static int idp_check_dp(DIST_POINT_NAME *a, DIST_POINT_NAME *b)
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
if (!GENERAL_NAME_cmp(gena, genb))
|
1367
|
-
return 1;
|
1368
|
-
}
|
1369
|
-
}
|
1370
|
-
|
1371
|
-
return 0;
|
1372
|
-
|
1373
|
-
}
|
1301
|
+
{
|
1302
|
+
X509_NAME *nm = NULL;
|
1303
|
+
GENERAL_NAMES *gens = NULL;
|
1304
|
+
GENERAL_NAME *gena, *genb;
|
1305
|
+
size_t i, j;
|
1306
|
+
if (!a || !b)
|
1307
|
+
return 1;
|
1308
|
+
if (a->type == 1) {
|
1309
|
+
if (!a->dpname)
|
1310
|
+
return 0;
|
1311
|
+
/* Case 1: two X509_NAME */
|
1312
|
+
if (b->type == 1) {
|
1313
|
+
if (!b->dpname)
|
1314
|
+
return 0;
|
1315
|
+
if (!X509_NAME_cmp(a->dpname, b->dpname))
|
1316
|
+
return 1;
|
1317
|
+
else
|
1318
|
+
return 0;
|
1319
|
+
}
|
1320
|
+
/* Case 2: set name and GENERAL_NAMES appropriately */
|
1321
|
+
nm = a->dpname;
|
1322
|
+
gens = b->name.fullname;
|
1323
|
+
} else if (b->type == 1) {
|
1324
|
+
if (!b->dpname)
|
1325
|
+
return 0;
|
1326
|
+
/* Case 2: set name and GENERAL_NAMES appropriately */
|
1327
|
+
gens = a->name.fullname;
|
1328
|
+
nm = b->dpname;
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
/* Handle case 2 with one GENERAL_NAMES and one X509_NAME */
|
1332
|
+
if (nm) {
|
1333
|
+
for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
|
1334
|
+
gena = sk_GENERAL_NAME_value(gens, i);
|
1335
|
+
if (gena->type != GEN_DIRNAME)
|
1336
|
+
continue;
|
1337
|
+
if (!X509_NAME_cmp(nm, gena->d.directoryName))
|
1338
|
+
return 1;
|
1339
|
+
}
|
1340
|
+
return 0;
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
/* Else case 3: two GENERAL_NAMES */
|
1344
|
+
|
1345
|
+
for (i = 0; i < sk_GENERAL_NAME_num(a->name.fullname); i++) {
|
1346
|
+
gena = sk_GENERAL_NAME_value(a->name.fullname, i);
|
1347
|
+
for (j = 0; j < sk_GENERAL_NAME_num(b->name.fullname); j++) {
|
1348
|
+
genb = sk_GENERAL_NAME_value(b->name.fullname, j);
|
1349
|
+
if (!GENERAL_NAME_cmp(gena, genb))
|
1350
|
+
return 1;
|
1351
|
+
}
|
1352
|
+
}
|
1353
|
+
|
1354
|
+
return 0;
|
1355
|
+
|
1356
|
+
}
|
1374
1357
|
|
1375
1358
|
static int crldp_check_crlissuer(DIST_POINT *dp, X509_CRL *crl, int crl_score)
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
}
|
1359
|
+
{
|
1360
|
+
size_t i;
|
1361
|
+
X509_NAME *nm = X509_CRL_get_issuer(crl);
|
1362
|
+
/* If no CRLissuer return is successful iff don't need a match */
|
1363
|
+
if (!dp->CRLissuer)
|
1364
|
+
return ! !(crl_score & CRL_SCORE_ISSUER_NAME);
|
1365
|
+
for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) {
|
1366
|
+
GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
|
1367
|
+
if (gen->type != GEN_DIRNAME)
|
1368
|
+
continue;
|
1369
|
+
if (!X509_NAME_cmp(gen->d.directoryName, nm))
|
1370
|
+
return 1;
|
1371
|
+
}
|
1372
|
+
return 0;
|
1373
|
+
}
|
1392
1374
|
|
1393
1375
|
/* Check CRLDP and IDP */
|
1394
1376
|
|
1395
1377
|
static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score,
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
return 0;
|
1428
|
-
}
|
1429
|
-
|
1430
|
-
/* Retrieve CRL corresponding to current certificate.
|
1431
|
-
* If deltas enabled try to find a delta CRL too
|
1378
|
+
unsigned int *preasons)
|
1379
|
+
{
|
1380
|
+
size_t i;
|
1381
|
+
if (crl->idp_flags & IDP_ONLYATTR)
|
1382
|
+
return 0;
|
1383
|
+
if (x->ex_flags & EXFLAG_CA) {
|
1384
|
+
if (crl->idp_flags & IDP_ONLYUSER)
|
1385
|
+
return 0;
|
1386
|
+
} else {
|
1387
|
+
if (crl->idp_flags & IDP_ONLYCA)
|
1388
|
+
return 0;
|
1389
|
+
}
|
1390
|
+
*preasons = crl->idp_reasons;
|
1391
|
+
for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) {
|
1392
|
+
DIST_POINT *dp = sk_DIST_POINT_value(x->crldp, i);
|
1393
|
+
if (crldp_check_crlissuer(dp, crl, crl_score)) {
|
1394
|
+
if (!crl->idp || idp_check_dp(dp->distpoint, crl->idp->distpoint)) {
|
1395
|
+
*preasons &= dp->dp_reasons;
|
1396
|
+
return 1;
|
1397
|
+
}
|
1398
|
+
}
|
1399
|
+
}
|
1400
|
+
if ((!crl->idp || !crl->idp->distpoint)
|
1401
|
+
&& (crl_score & CRL_SCORE_ISSUER_NAME))
|
1402
|
+
return 1;
|
1403
|
+
return 0;
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
/*
|
1407
|
+
* Retrieve CRL corresponding to current certificate. If deltas enabled try
|
1408
|
+
* to find a delta CRL too
|
1432
1409
|
*/
|
1433
|
-
|
1410
|
+
|
1434
1411
|
static int get_crl_delta(X509_STORE_CTX *ctx,
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
}
|
1412
|
+
X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x)
|
1413
|
+
{
|
1414
|
+
int ok;
|
1415
|
+
X509 *issuer = NULL;
|
1416
|
+
int crl_score = 0;
|
1417
|
+
unsigned int reasons;
|
1418
|
+
X509_CRL *crl = NULL, *dcrl = NULL;
|
1419
|
+
STACK_OF(X509_CRL) *skcrl;
|
1420
|
+
X509_NAME *nm = X509_get_issuer_name(x);
|
1421
|
+
reasons = ctx->current_reasons;
|
1422
|
+
ok = get_crl_sk(ctx, &crl, &dcrl,
|
1423
|
+
&issuer, &crl_score, &reasons, ctx->crls);
|
1424
|
+
|
1425
|
+
if (ok)
|
1426
|
+
goto done;
|
1427
|
+
|
1428
|
+
/* Lookup CRLs from store */
|
1429
|
+
|
1430
|
+
skcrl = ctx->lookup_crls(ctx, nm);
|
1431
|
+
|
1432
|
+
/* If no CRLs found and a near match from get_crl_sk use that */
|
1433
|
+
if (!skcrl && crl)
|
1434
|
+
goto done;
|
1435
|
+
|
1436
|
+
get_crl_sk(ctx, &crl, &dcrl, &issuer, &crl_score, &reasons, skcrl);
|
1437
|
+
|
1438
|
+
sk_X509_CRL_pop_free(skcrl, X509_CRL_free);
|
1439
|
+
|
1440
|
+
done:
|
1441
|
+
|
1442
|
+
/* If we got any kind of CRL use it and return success */
|
1443
|
+
if (crl) {
|
1444
|
+
ctx->current_issuer = issuer;
|
1445
|
+
ctx->current_crl_score = crl_score;
|
1446
|
+
ctx->current_reasons = reasons;
|
1447
|
+
*pcrl = crl;
|
1448
|
+
*pdcrl = dcrl;
|
1449
|
+
return 1;
|
1450
|
+
}
|
1451
|
+
|
1452
|
+
return 0;
|
1453
|
+
}
|
1478
1454
|
|
1479
1455
|
/* Check CRL validity */
|
1480
1456
|
static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl)
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
}
|
1587
|
-
|
1588
|
-
ok = 1;
|
1589
|
-
|
1590
|
-
err:
|
1591
|
-
EVP_PKEY_free(ikey);
|
1592
|
-
return ok;
|
1593
|
-
}
|
1457
|
+
{
|
1458
|
+
X509 *issuer = NULL;
|
1459
|
+
EVP_PKEY *ikey = NULL;
|
1460
|
+
int ok = 0, chnum, cnum;
|
1461
|
+
cnum = ctx->error_depth;
|
1462
|
+
chnum = sk_X509_num(ctx->chain) - 1;
|
1463
|
+
/* if we have an alternative CRL issuer cert use that */
|
1464
|
+
if (ctx->current_issuer)
|
1465
|
+
issuer = ctx->current_issuer;
|
1466
|
+
|
1467
|
+
/*
|
1468
|
+
* Else find CRL issuer: if not last certificate then issuer is next
|
1469
|
+
* certificate in chain.
|
1470
|
+
*/
|
1471
|
+
else if (cnum < chnum)
|
1472
|
+
issuer = sk_X509_value(ctx->chain, cnum + 1);
|
1473
|
+
else {
|
1474
|
+
issuer = sk_X509_value(ctx->chain, chnum);
|
1475
|
+
/* If not self signed, can't check signature */
|
1476
|
+
if (!ctx->check_issued(ctx, issuer, issuer)) {
|
1477
|
+
ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER;
|
1478
|
+
ok = ctx->verify_cb(0, ctx);
|
1479
|
+
if (!ok)
|
1480
|
+
goto err;
|
1481
|
+
}
|
1482
|
+
}
|
1483
|
+
|
1484
|
+
if (issuer) {
|
1485
|
+
/*
|
1486
|
+
* Skip most tests for deltas because they have already been done
|
1487
|
+
*/
|
1488
|
+
if (!crl->base_crl_number) {
|
1489
|
+
/* Check for cRLSign bit if keyUsage present */
|
1490
|
+
if ((issuer->ex_flags & EXFLAG_KUSAGE) &&
|
1491
|
+
!(issuer->ex_kusage & KU_CRL_SIGN)) {
|
1492
|
+
ctx->error = X509_V_ERR_KEYUSAGE_NO_CRL_SIGN;
|
1493
|
+
ok = ctx->verify_cb(0, ctx);
|
1494
|
+
if (!ok)
|
1495
|
+
goto err;
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
if (!(ctx->current_crl_score & CRL_SCORE_SCOPE)) {
|
1499
|
+
ctx->error = X509_V_ERR_DIFFERENT_CRL_SCOPE;
|
1500
|
+
ok = ctx->verify_cb(0, ctx);
|
1501
|
+
if (!ok)
|
1502
|
+
goto err;
|
1503
|
+
}
|
1504
|
+
|
1505
|
+
if (!(ctx->current_crl_score & CRL_SCORE_SAME_PATH)) {
|
1506
|
+
if (check_crl_path(ctx, ctx->current_issuer) <= 0) {
|
1507
|
+
ctx->error = X509_V_ERR_CRL_PATH_VALIDATION_ERROR;
|
1508
|
+
ok = ctx->verify_cb(0, ctx);
|
1509
|
+
if (!ok)
|
1510
|
+
goto err;
|
1511
|
+
}
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
if (crl->idp_flags & IDP_INVALID) {
|
1515
|
+
ctx->error = X509_V_ERR_INVALID_EXTENSION;
|
1516
|
+
ok = ctx->verify_cb(0, ctx);
|
1517
|
+
if (!ok)
|
1518
|
+
goto err;
|
1519
|
+
}
|
1520
|
+
|
1521
|
+
}
|
1522
|
+
|
1523
|
+
if (!(ctx->current_crl_score & CRL_SCORE_TIME)) {
|
1524
|
+
ok = check_crl_time(ctx, crl, 1);
|
1525
|
+
if (!ok)
|
1526
|
+
goto err;
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
/* Attempt to get issuer certificate public key */
|
1530
|
+
ikey = X509_get_pubkey(issuer);
|
1531
|
+
|
1532
|
+
if (!ikey) {
|
1533
|
+
ctx->error = X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
|
1534
|
+
ok = ctx->verify_cb(0, ctx);
|
1535
|
+
if (!ok)
|
1536
|
+
goto err;
|
1537
|
+
} else {
|
1538
|
+
int rv;
|
1539
|
+
rv = X509_CRL_check_suiteb(crl, ikey, ctx->param->flags);
|
1540
|
+
if (rv != X509_V_OK) {
|
1541
|
+
ctx->error = rv;
|
1542
|
+
ok = ctx->verify_cb(0, ctx);
|
1543
|
+
if (!ok)
|
1544
|
+
goto err;
|
1545
|
+
}
|
1546
|
+
/* Verify CRL signature */
|
1547
|
+
if (X509_CRL_verify(crl, ikey) <= 0) {
|
1548
|
+
ctx->error = X509_V_ERR_CRL_SIGNATURE_FAILURE;
|
1549
|
+
ok = ctx->verify_cb(0, ctx);
|
1550
|
+
if (!ok)
|
1551
|
+
goto err;
|
1552
|
+
}
|
1553
|
+
}
|
1554
|
+
}
|
1555
|
+
|
1556
|
+
ok = 1;
|
1557
|
+
|
1558
|
+
err:
|
1559
|
+
EVP_PKEY_free(ikey);
|
1560
|
+
return ok;
|
1561
|
+
}
|
1594
1562
|
|
1595
1563
|
/* Check certificate against CRL */
|
1596
1564
|
static int cert_crl(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x)
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1565
|
+
{
|
1566
|
+
int ok;
|
1567
|
+
X509_REVOKED *rev;
|
1568
|
+
/*
|
1569
|
+
* The rules changed for this... previously if a CRL contained unhandled
|
1570
|
+
* critical extensions it could still be used to indicate a certificate
|
1571
|
+
* was revoked. This has since been changed since critical extension can
|
1572
|
+
* change the meaning of CRL entries.
|
1573
|
+
*/
|
1574
|
+
if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
|
1575
|
+
&& (crl->flags & EXFLAG_CRITICAL)) {
|
1576
|
+
ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION;
|
1577
|
+
ok = ctx->verify_cb(0, ctx);
|
1578
|
+
if (!ok)
|
1579
|
+
return 0;
|
1580
|
+
}
|
1581
|
+
/*
|
1582
|
+
* Look for serial number of certificate in CRL If found make sure reason
|
1583
|
+
* is not removeFromCRL.
|
1584
|
+
*/
|
1585
|
+
if (X509_CRL_get0_by_cert(crl, &rev, x)) {
|
1586
|
+
if (rev->reason == CRL_REASON_REMOVE_FROM_CRL)
|
1587
|
+
return 2;
|
1588
|
+
ctx->error = X509_V_ERR_CERT_REVOKED;
|
1589
|
+
ok = ctx->verify_cb(0, ctx);
|
1590
|
+
if (!ok)
|
1591
|
+
return 0;
|
1592
|
+
}
|
1593
|
+
|
1594
|
+
return 1;
|
1595
|
+
}
|
1628
1596
|
|
1629
1597
|
static int check_policy(X509_STORE_CTX *ctx)
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
return 0;
|
1674
|
-
}
|
1675
|
-
|
1676
|
-
return 1;
|
1677
|
-
}
|
1598
|
+
{
|
1599
|
+
int ret;
|
1600
|
+
if (ctx->parent)
|
1601
|
+
return 1;
|
1602
|
+
ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain,
|
1603
|
+
ctx->param->policies, ctx->param->flags);
|
1604
|
+
if (ret == 0) {
|
1605
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
1606
|
+
return 0;
|
1607
|
+
}
|
1608
|
+
/* Invalid or inconsistent extensions */
|
1609
|
+
if (ret == -1) {
|
1610
|
+
/*
|
1611
|
+
* Locate certificates with bad extensions and notify callback.
|
1612
|
+
*/
|
1613
|
+
X509 *x;
|
1614
|
+
size_t i;
|
1615
|
+
for (i = 1; i < sk_X509_num(ctx->chain); i++) {
|
1616
|
+
x = sk_X509_value(ctx->chain, i);
|
1617
|
+
if (!(x->ex_flags & EXFLAG_INVALID_POLICY))
|
1618
|
+
continue;
|
1619
|
+
ctx->current_cert = x;
|
1620
|
+
ctx->error = X509_V_ERR_INVALID_POLICY_EXTENSION;
|
1621
|
+
if (!ctx->verify_cb(0, ctx))
|
1622
|
+
return 0;
|
1623
|
+
}
|
1624
|
+
return 1;
|
1625
|
+
}
|
1626
|
+
if (ret == -2) {
|
1627
|
+
ctx->current_cert = NULL;
|
1628
|
+
ctx->error = X509_V_ERR_NO_EXPLICIT_POLICY;
|
1629
|
+
return ctx->verify_cb(0, ctx);
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
if (ctx->param->flags & X509_V_FLAG_NOTIFY_POLICY) {
|
1633
|
+
ctx->current_cert = NULL;
|
1634
|
+
ctx->error = X509_V_OK;
|
1635
|
+
if (!ctx->verify_cb(2, ctx))
|
1636
|
+
return 0;
|
1637
|
+
}
|
1638
|
+
|
1639
|
+
return 1;
|
1640
|
+
}
|
1678
1641
|
|
1679
1642
|
static int check_cert_time(X509_STORE_CTX *ctx, X509 *x)
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
}
|
1722
|
-
|
1723
|
-
return 1;
|
1724
|
-
}
|
1643
|
+
{
|
1644
|
+
time_t *ptime;
|
1645
|
+
int i;
|
1646
|
+
|
1647
|
+
if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
|
1648
|
+
ptime = &ctx->param->check_time;
|
1649
|
+
else
|
1650
|
+
ptime = NULL;
|
1651
|
+
|
1652
|
+
i = X509_cmp_time(X509_get_notBefore(x), ptime);
|
1653
|
+
if (i == 0) {
|
1654
|
+
ctx->error = X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD;
|
1655
|
+
ctx->current_cert = x;
|
1656
|
+
if (!ctx->verify_cb(0, ctx))
|
1657
|
+
return 0;
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
if (i > 0) {
|
1661
|
+
ctx->error = X509_V_ERR_CERT_NOT_YET_VALID;
|
1662
|
+
ctx->current_cert = x;
|
1663
|
+
if (!ctx->verify_cb(0, ctx))
|
1664
|
+
return 0;
|
1665
|
+
}
|
1666
|
+
|
1667
|
+
i = X509_cmp_time(X509_get_notAfter(x), ptime);
|
1668
|
+
if (i == 0) {
|
1669
|
+
ctx->error = X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD;
|
1670
|
+
ctx->current_cert = x;
|
1671
|
+
if (!ctx->verify_cb(0, ctx))
|
1672
|
+
return 0;
|
1673
|
+
}
|
1674
|
+
|
1675
|
+
if (i < 0) {
|
1676
|
+
ctx->error = X509_V_ERR_CERT_HAS_EXPIRED;
|
1677
|
+
ctx->current_cert = x;
|
1678
|
+
if (!ctx->verify_cb(0, ctx))
|
1679
|
+
return 0;
|
1680
|
+
}
|
1681
|
+
|
1682
|
+
return 1;
|
1683
|
+
}
|
1725
1684
|
|
1726
1685
|
static int internal_verify(X509_STORE_CTX *ctx)
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
xs=sk_X509_value(ctx->chain,n);
|
1815
|
-
}
|
1816
|
-
}
|
1817
|
-
ok=1;
|
1818
|
-
end:
|
1819
|
-
return ok;
|
1820
|
-
}
|
1686
|
+
{
|
1687
|
+
int ok = 0, n;
|
1688
|
+
X509 *xs, *xi;
|
1689
|
+
EVP_PKEY *pkey = NULL;
|
1690
|
+
int (*cb) (int xok, X509_STORE_CTX *xctx);
|
1691
|
+
|
1692
|
+
cb = ctx->verify_cb;
|
1693
|
+
|
1694
|
+
n = sk_X509_num(ctx->chain);
|
1695
|
+
ctx->error_depth = n - 1;
|
1696
|
+
n--;
|
1697
|
+
xi = sk_X509_value(ctx->chain, n);
|
1698
|
+
|
1699
|
+
if (ctx->check_issued(ctx, xi, xi))
|
1700
|
+
xs = xi;
|
1701
|
+
else {
|
1702
|
+
if (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) {
|
1703
|
+
xs = xi;
|
1704
|
+
goto check_cert;
|
1705
|
+
}
|
1706
|
+
if (n <= 0) {
|
1707
|
+
ctx->error = X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
|
1708
|
+
ctx->current_cert = xi;
|
1709
|
+
ok = cb(0, ctx);
|
1710
|
+
goto end;
|
1711
|
+
} else {
|
1712
|
+
n--;
|
1713
|
+
ctx->error_depth = n;
|
1714
|
+
xs = sk_X509_value(ctx->chain, n);
|
1715
|
+
}
|
1716
|
+
}
|
1717
|
+
|
1718
|
+
/* ctx->error=0; not needed */
|
1719
|
+
while (n >= 0) {
|
1720
|
+
ctx->error_depth = n;
|
1721
|
+
|
1722
|
+
/*
|
1723
|
+
* Skip signature check for self signed certificates unless
|
1724
|
+
* explicitly asked for. It doesn't add any security and just wastes
|
1725
|
+
* time.
|
1726
|
+
*/
|
1727
|
+
if (!xs->valid
|
1728
|
+
&& (xs != xi
|
1729
|
+
|| (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE))) {
|
1730
|
+
if ((pkey = X509_get_pubkey(xi)) == NULL) {
|
1731
|
+
ctx->error = X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
|
1732
|
+
ctx->current_cert = xi;
|
1733
|
+
ok = (*cb) (0, ctx);
|
1734
|
+
if (!ok)
|
1735
|
+
goto end;
|
1736
|
+
} else if (X509_verify(xs, pkey) <= 0) {
|
1737
|
+
ctx->error = X509_V_ERR_CERT_SIGNATURE_FAILURE;
|
1738
|
+
ctx->current_cert = xs;
|
1739
|
+
ok = (*cb) (0, ctx);
|
1740
|
+
if (!ok) {
|
1741
|
+
EVP_PKEY_free(pkey);
|
1742
|
+
goto end;
|
1743
|
+
}
|
1744
|
+
}
|
1745
|
+
EVP_PKEY_free(pkey);
|
1746
|
+
pkey = NULL;
|
1747
|
+
}
|
1748
|
+
|
1749
|
+
xs->valid = 1;
|
1750
|
+
|
1751
|
+
check_cert:
|
1752
|
+
ok = check_cert_time(ctx, xs);
|
1753
|
+
if (!ok)
|
1754
|
+
goto end;
|
1755
|
+
|
1756
|
+
/* The last error (if any) is still in the error value */
|
1757
|
+
ctx->current_issuer = xi;
|
1758
|
+
ctx->current_cert = xs;
|
1759
|
+
ok = (*cb) (1, ctx);
|
1760
|
+
if (!ok)
|
1761
|
+
goto end;
|
1762
|
+
|
1763
|
+
n--;
|
1764
|
+
if (n >= 0) {
|
1765
|
+
xi = xs;
|
1766
|
+
xs = sk_X509_value(ctx->chain, n);
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
ok = 1;
|
1770
|
+
end:
|
1771
|
+
return ok;
|
1772
|
+
}
|
1821
1773
|
|
1822
1774
|
int X509_cmp_current_time(const ASN1_TIME *ctm)
|
1823
1775
|
{
|
1824
|
-
|
1776
|
+
return X509_cmp_time(ctm, NULL);
|
1825
1777
|
}
|
1826
1778
|
|
1827
1779
|
int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time)
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1780
|
+
{
|
1781
|
+
char *str;
|
1782
|
+
ASN1_TIME atm;
|
1783
|
+
long offset;
|
1784
|
+
char buff1[24], buff2[24], *p;
|
1785
|
+
int i, j, remaining;
|
1786
|
+
|
1787
|
+
p = buff1;
|
1788
|
+
remaining = ctm->length;
|
1789
|
+
str = (char *)ctm->data;
|
1790
|
+
/*
|
1791
|
+
* Note that the following (historical) code allows much more slack in
|
1792
|
+
* the time format than RFC5280. In RFC5280, the representation is fixed:
|
1793
|
+
* UTCTime: YYMMDDHHMMSSZ GeneralizedTime: YYYYMMDDHHMMSSZ
|
1794
|
+
*/
|
1795
|
+
if (ctm->type == V_ASN1_UTCTIME) {
|
1796
|
+
/* YYMMDDHHMM[SS]Z or YYMMDDHHMM[SS](+-)hhmm */
|
1797
|
+
int min_length = sizeof("YYMMDDHHMMZ") - 1;
|
1798
|
+
int max_length = sizeof("YYMMDDHHMMSS+hhmm") - 1;
|
1799
|
+
if (remaining < min_length || remaining > max_length)
|
1800
|
+
return 0;
|
1801
|
+
memcpy(p, str, 10);
|
1802
|
+
p += 10;
|
1803
|
+
str += 10;
|
1804
|
+
remaining -= 10;
|
1805
|
+
} else {
|
1806
|
+
/*
|
1807
|
+
* YYYYMMDDHHMM[SS[.fff]]Z or YYYYMMDDHHMM[SS[.f[f[f]]]](+-)hhmm
|
1808
|
+
*/
|
1809
|
+
int min_length = sizeof("YYYYMMDDHHMMZ") - 1;
|
1810
|
+
int max_length = sizeof("YYYYMMDDHHMMSS.fff+hhmm") - 1;
|
1811
|
+
if (remaining < min_length || remaining > max_length)
|
1812
|
+
return 0;
|
1813
|
+
memcpy(p, str, 12);
|
1814
|
+
p += 12;
|
1815
|
+
str += 12;
|
1816
|
+
remaining -= 12;
|
1817
|
+
}
|
1818
|
+
|
1819
|
+
if ((*str == 'Z') || (*str == '-') || (*str == '+')) {
|
1820
|
+
*(p++) = '0';
|
1821
|
+
*(p++) = '0';
|
1822
|
+
} else {
|
1823
|
+
/* SS (seconds) */
|
1824
|
+
if (remaining < 2)
|
1825
|
+
return 0;
|
1826
|
+
*(p++) = *(str++);
|
1827
|
+
*(p++) = *(str++);
|
1828
|
+
remaining -= 2;
|
1829
|
+
/*
|
1830
|
+
* Skip any (up to three) fractional seconds... TODO(emilia): in
|
1831
|
+
* RFC5280, fractional seconds are forbidden. Can we just kill them
|
1832
|
+
* altogether?
|
1833
|
+
*/
|
1834
|
+
if (remaining && *str == '.') {
|
1835
|
+
str++;
|
1836
|
+
remaining--;
|
1837
|
+
for (i = 0; i < 3 && remaining; i++, str++, remaining--) {
|
1838
|
+
if (*str < '0' || *str > '9')
|
1839
|
+
break;
|
1840
|
+
}
|
1841
|
+
}
|
1842
|
+
|
1843
|
+
}
|
1844
|
+
*(p++) = 'Z';
|
1845
|
+
*(p++) = '\0';
|
1846
|
+
|
1847
|
+
/* We now need either a terminating 'Z' or an offset. */
|
1848
|
+
if (!remaining)
|
1849
|
+
return 0;
|
1850
|
+
if (*str == 'Z') {
|
1851
|
+
if (remaining != 1)
|
1852
|
+
return 0;
|
1853
|
+
offset = 0;
|
1854
|
+
} else {
|
1855
|
+
/* (+-)HHMM */
|
1856
|
+
if ((*str != '+') && (*str != '-'))
|
1857
|
+
return 0;
|
1858
|
+
/*
|
1859
|
+
* Historical behaviour: the (+-)hhmm offset is forbidden in RFC5280.
|
1860
|
+
*/
|
1861
|
+
if (remaining != 5)
|
1862
|
+
return 0;
|
1863
|
+
if (str[1] < '0' || str[1] > '9' || str[2] < '0' || str[2] > '9' ||
|
1864
|
+
str[3] < '0' || str[3] > '9' || str[4] < '0' || str[4] > '9')
|
1865
|
+
return 0;
|
1866
|
+
offset = ((str[1] - '0') * 10 + (str[2] - '0')) * 60;
|
1867
|
+
offset += (str[3] - '0') * 10 + (str[4] - '0');
|
1868
|
+
if (*str == '-')
|
1869
|
+
offset = -offset;
|
1870
|
+
}
|
1871
|
+
atm.type = ctm->type;
|
1872
|
+
atm.flags = 0;
|
1873
|
+
atm.length = sizeof(buff2);
|
1874
|
+
atm.data = (unsigned char *)buff2;
|
1875
|
+
|
1876
|
+
if (X509_time_adj(&atm, offset * 60, cmp_time) == NULL)
|
1877
|
+
return 0;
|
1878
|
+
|
1879
|
+
if (ctm->type == V_ASN1_UTCTIME) {
|
1880
|
+
i = (buff1[0] - '0') * 10 + (buff1[1] - '0');
|
1881
|
+
if (i < 50)
|
1882
|
+
i += 100; /* cf. RFC 2459 */
|
1883
|
+
j = (buff2[0] - '0') * 10 + (buff2[1] - '0');
|
1884
|
+
if (j < 50)
|
1885
|
+
j += 100;
|
1886
|
+
|
1887
|
+
if (i < j)
|
1888
|
+
return -1;
|
1889
|
+
if (i > j)
|
1890
|
+
return 1;
|
1891
|
+
}
|
1892
|
+
i = strcmp(buff1, buff2);
|
1893
|
+
if (i == 0) /* wait a second then return younger :-) */
|
1894
|
+
return -1;
|
1895
|
+
else
|
1896
|
+
return i;
|
1897
|
+
}
|
1945
1898
|
|
1946
1899
|
ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj)
|
1947
1900
|
{
|
1948
|
-
|
1901
|
+
return X509_time_adj(s, adj, NULL);
|
1949
1902
|
}
|
1950
1903
|
|
1951
1904
|
ASN1_TIME *X509_time_adj(ASN1_TIME *s, long offset_sec, time_t *in_tm)
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1905
|
+
{
|
1906
|
+
return X509_time_adj_ex(s, 0, offset_sec, in_tm);
|
1907
|
+
}
|
1955
1908
|
|
1956
1909
|
ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1910
|
+
int offset_day, long offset_sec, time_t *in_tm)
|
1911
|
+
{
|
1912
|
+
time_t t = 0;
|
1913
|
+
|
1914
|
+
if (in_tm)
|
1915
|
+
t = *in_tm;
|
1916
|
+
else
|
1917
|
+
time(&t);
|
1918
|
+
|
1919
|
+
if (s && !(s->flags & ASN1_STRING_FLAG_MSTRING)) {
|
1920
|
+
if (s->type == V_ASN1_UTCTIME)
|
1921
|
+
return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec);
|
1922
|
+
if (s->type == V_ASN1_GENERALIZEDTIME)
|
1923
|
+
return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
|
1924
|
+
}
|
1925
|
+
return ASN1_TIME_adj(s, t, offset_day, offset_sec);
|
1926
|
+
}
|
1974
1927
|
|
1975
1928
|
/* Make a delta CRL as the diff between two full CRLs */
|
1976
1929
|
|
1977
1930
|
X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
int index;
|
2101
|
-
if (!CRYPTO_get_ex_new_index(&g_ex_data_class, &index, argl, argp,
|
2102
|
-
dup_func, free_func))
|
2103
|
-
{
|
2104
|
-
return -1;
|
2105
|
-
}
|
2106
|
-
return index;
|
2107
|
-
}
|
1931
|
+
EVP_PKEY *skey, const EVP_MD *md, unsigned int flags)
|
1932
|
+
{
|
1933
|
+
X509_CRL *crl = NULL;
|
1934
|
+
int i;
|
1935
|
+
size_t j;
|
1936
|
+
STACK_OF(X509_REVOKED) *revs = NULL;
|
1937
|
+
/* CRLs can't be delta already */
|
1938
|
+
if (base->base_crl_number || newer->base_crl_number) {
|
1939
|
+
OPENSSL_PUT_ERROR(X509, X509_R_CRL_ALREADY_DELTA);
|
1940
|
+
return NULL;
|
1941
|
+
}
|
1942
|
+
/* Base and new CRL must have a CRL number */
|
1943
|
+
if (!base->crl_number || !newer->crl_number) {
|
1944
|
+
OPENSSL_PUT_ERROR(X509, X509_R_NO_CRL_NUMBER);
|
1945
|
+
return NULL;
|
1946
|
+
}
|
1947
|
+
/* Issuer names must match */
|
1948
|
+
if (X509_NAME_cmp(X509_CRL_get_issuer(base), X509_CRL_get_issuer(newer))) {
|
1949
|
+
OPENSSL_PUT_ERROR(X509, X509_R_ISSUER_MISMATCH);
|
1950
|
+
return NULL;
|
1951
|
+
}
|
1952
|
+
/* AKID and IDP must match */
|
1953
|
+
if (!crl_extension_match(base, newer, NID_authority_key_identifier)) {
|
1954
|
+
OPENSSL_PUT_ERROR(X509, X509_R_AKID_MISMATCH);
|
1955
|
+
return NULL;
|
1956
|
+
}
|
1957
|
+
if (!crl_extension_match(base, newer, NID_issuing_distribution_point)) {
|
1958
|
+
OPENSSL_PUT_ERROR(X509, X509_R_IDP_MISMATCH);
|
1959
|
+
return NULL;
|
1960
|
+
}
|
1961
|
+
/* Newer CRL number must exceed full CRL number */
|
1962
|
+
if (ASN1_INTEGER_cmp(newer->crl_number, base->crl_number) <= 0) {
|
1963
|
+
OPENSSL_PUT_ERROR(X509, X509_R_NEWER_CRL_NOT_NEWER);
|
1964
|
+
return NULL;
|
1965
|
+
}
|
1966
|
+
/* CRLs must verify */
|
1967
|
+
if (skey && (X509_CRL_verify(base, skey) <= 0 ||
|
1968
|
+
X509_CRL_verify(newer, skey) <= 0)) {
|
1969
|
+
OPENSSL_PUT_ERROR(X509, X509_R_CRL_VERIFY_FAILURE);
|
1970
|
+
return NULL;
|
1971
|
+
}
|
1972
|
+
/* Create new CRL */
|
1973
|
+
crl = X509_CRL_new();
|
1974
|
+
if (!crl || !X509_CRL_set_version(crl, 1))
|
1975
|
+
goto memerr;
|
1976
|
+
/* Set issuer name */
|
1977
|
+
if (!X509_CRL_set_issuer_name(crl, X509_CRL_get_issuer(newer)))
|
1978
|
+
goto memerr;
|
1979
|
+
|
1980
|
+
if (!X509_CRL_set_lastUpdate(crl, X509_CRL_get_lastUpdate(newer)))
|
1981
|
+
goto memerr;
|
1982
|
+
if (!X509_CRL_set_nextUpdate(crl, X509_CRL_get_nextUpdate(newer)))
|
1983
|
+
goto memerr;
|
1984
|
+
|
1985
|
+
/* Set base CRL number: must be critical */
|
1986
|
+
|
1987
|
+
if (!X509_CRL_add1_ext_i2d(crl, NID_delta_crl, base->crl_number, 1, 0))
|
1988
|
+
goto memerr;
|
1989
|
+
|
1990
|
+
/*
|
1991
|
+
* Copy extensions across from newest CRL to delta: this will set CRL
|
1992
|
+
* number to correct value too.
|
1993
|
+
*/
|
1994
|
+
|
1995
|
+
for (i = 0; i < X509_CRL_get_ext_count(newer); i++) {
|
1996
|
+
X509_EXTENSION *ext;
|
1997
|
+
ext = X509_CRL_get_ext(newer, i);
|
1998
|
+
if (!X509_CRL_add_ext(crl, ext, -1))
|
1999
|
+
goto memerr;
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
/* Go through revoked entries, copying as needed */
|
2003
|
+
|
2004
|
+
revs = X509_CRL_get_REVOKED(newer);
|
2005
|
+
|
2006
|
+
for (j = 0; j < sk_X509_REVOKED_num(revs); j++) {
|
2007
|
+
X509_REVOKED *rvn, *rvtmp;
|
2008
|
+
rvn = sk_X509_REVOKED_value(revs, j);
|
2009
|
+
/*
|
2010
|
+
* Add only if not also in base. TODO: need something cleverer here
|
2011
|
+
* for some more complex CRLs covering multiple CAs.
|
2012
|
+
*/
|
2013
|
+
if (!X509_CRL_get0_by_serial(base, &rvtmp, rvn->serialNumber)) {
|
2014
|
+
rvtmp = X509_REVOKED_dup(rvn);
|
2015
|
+
if (!rvtmp)
|
2016
|
+
goto memerr;
|
2017
|
+
if (!X509_CRL_add0_revoked(crl, rvtmp)) {
|
2018
|
+
X509_REVOKED_free(rvtmp);
|
2019
|
+
goto memerr;
|
2020
|
+
}
|
2021
|
+
}
|
2022
|
+
}
|
2023
|
+
/* TODO: optionally prune deleted entries */
|
2024
|
+
|
2025
|
+
if (skey && md && !X509_CRL_sign(crl, skey, md))
|
2026
|
+
goto memerr;
|
2027
|
+
|
2028
|
+
return crl;
|
2029
|
+
|
2030
|
+
memerr:
|
2031
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
2032
|
+
if (crl)
|
2033
|
+
X509_CRL_free(crl);
|
2034
|
+
return NULL;
|
2035
|
+
}
|
2036
|
+
|
2037
|
+
int X509_STORE_CTX_get_ex_new_index(long argl, void *argp,
|
2038
|
+
CRYPTO_EX_unused * unused,
|
2039
|
+
CRYPTO_EX_dup *dup_func,
|
2040
|
+
CRYPTO_EX_free *free_func)
|
2041
|
+
{
|
2042
|
+
/*
|
2043
|
+
* This function is (usually) called only once, by
|
2044
|
+
* SSL_get_ex_data_X509_STORE_CTX_idx (ssl/ssl_cert.c).
|
2045
|
+
*/
|
2046
|
+
int index;
|
2047
|
+
if (!CRYPTO_get_ex_new_index(&g_ex_data_class, &index, argl, argp,
|
2048
|
+
dup_func, free_func)) {
|
2049
|
+
return -1;
|
2050
|
+
}
|
2051
|
+
return index;
|
2052
|
+
}
|
2108
2053
|
|
2109
2054
|
int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data)
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2055
|
+
{
|
2056
|
+
return CRYPTO_set_ex_data(&ctx->ex_data, idx, data);
|
2057
|
+
}
|
2113
2058
|
|
2114
2059
|
void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx)
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2060
|
+
{
|
2061
|
+
return CRYPTO_get_ex_data(&ctx->ex_data, idx);
|
2062
|
+
}
|
2118
2063
|
|
2119
2064
|
int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx)
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2065
|
+
{
|
2066
|
+
return ctx->error;
|
2067
|
+
}
|
2123
2068
|
|
2124
2069
|
void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int err)
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2070
|
+
{
|
2071
|
+
ctx->error = err;
|
2072
|
+
}
|
2128
2073
|
|
2129
2074
|
int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx)
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2075
|
+
{
|
2076
|
+
return ctx->error_depth;
|
2077
|
+
}
|
2133
2078
|
|
2134
2079
|
X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx)
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2080
|
+
{
|
2081
|
+
return ctx->current_cert;
|
2082
|
+
}
|
2138
2083
|
|
2139
2084
|
STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx)
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2085
|
+
{
|
2086
|
+
return ctx->chain;
|
2087
|
+
}
|
2143
2088
|
|
2144
2089
|
STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2090
|
+
{
|
2091
|
+
if (!ctx->chain)
|
2092
|
+
return NULL;
|
2093
|
+
return X509_chain_up_ref(ctx->chain);
|
2094
|
+
}
|
2150
2095
|
|
2151
2096
|
X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx)
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2097
|
+
{
|
2098
|
+
return ctx->current_issuer;
|
2099
|
+
}
|
2155
2100
|
|
2156
2101
|
X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx)
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2102
|
+
{
|
2103
|
+
return ctx->current_crl;
|
2104
|
+
}
|
2160
2105
|
|
2161
2106
|
X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx)
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2107
|
+
{
|
2108
|
+
return ctx->parent;
|
2109
|
+
}
|
2165
2110
|
|
2166
2111
|
void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2112
|
+
{
|
2113
|
+
ctx->cert = x;
|
2114
|
+
}
|
2170
2115
|
|
2171
2116
|
void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2117
|
+
{
|
2118
|
+
ctx->untrusted = sk;
|
2119
|
+
}
|
2175
2120
|
|
2176
2121
|
void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk)
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2122
|
+
{
|
2123
|
+
ctx->crls = sk;
|
2124
|
+
}
|
2180
2125
|
|
2181
2126
|
int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose)
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2127
|
+
{
|
2128
|
+
return X509_STORE_CTX_purpose_inherit(ctx, 0, purpose, 0);
|
2129
|
+
}
|
2185
2130
|
|
2186
2131
|
int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust)
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
/*
|
2192
|
-
*
|
2193
|
-
*
|
2194
|
-
* the ctx. If they aren't
|
2195
|
-
*
|
2196
|
-
* An example of this is SSL use: an SSL
|
2197
|
-
* purpose and trust settings which the
|
2198
|
-
* aren't set then we use the default of SSL
|
2132
|
+
{
|
2133
|
+
return X509_STORE_CTX_purpose_inherit(ctx, 0, 0, trust);
|
2134
|
+
}
|
2135
|
+
|
2136
|
+
/*
|
2137
|
+
* This function is used to set the X509_STORE_CTX purpose and trust values.
|
2138
|
+
* This is intended to be used when another structure has its own trust and
|
2139
|
+
* purpose values which (if set) will be inherited by the ctx. If they aren't
|
2140
|
+
* set then we will usually have a default purpose in mind which should then
|
2141
|
+
* be used to set the trust value. An example of this is SSL use: an SSL
|
2142
|
+
* structure will have its own purpose and trust settings which the
|
2143
|
+
* application can set: if they aren't set then we use the default of SSL
|
2144
|
+
* client/server.
|
2199
2145
|
*/
|
2200
2146
|
|
2201
2147
|
int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
|
2202
|
-
|
2203
|
-
{
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
if (trust && !ctx->param->trust) ctx->param->trust = trust;
|
2243
|
-
return 1;
|
2148
|
+
int purpose, int trust)
|
2149
|
+
{
|
2150
|
+
int idx;
|
2151
|
+
/* If purpose not set use default */
|
2152
|
+
if (!purpose)
|
2153
|
+
purpose = def_purpose;
|
2154
|
+
/* If we have a purpose then check it is valid */
|
2155
|
+
if (purpose) {
|
2156
|
+
X509_PURPOSE *ptmp;
|
2157
|
+
idx = X509_PURPOSE_get_by_id(purpose);
|
2158
|
+
if (idx == -1) {
|
2159
|
+
OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_PURPOSE_ID);
|
2160
|
+
return 0;
|
2161
|
+
}
|
2162
|
+
ptmp = X509_PURPOSE_get0(idx);
|
2163
|
+
if (ptmp->trust == X509_TRUST_DEFAULT) {
|
2164
|
+
idx = X509_PURPOSE_get_by_id(def_purpose);
|
2165
|
+
if (idx == -1) {
|
2166
|
+
OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_PURPOSE_ID);
|
2167
|
+
return 0;
|
2168
|
+
}
|
2169
|
+
ptmp = X509_PURPOSE_get0(idx);
|
2170
|
+
}
|
2171
|
+
/* If trust not set then get from purpose default */
|
2172
|
+
if (!trust)
|
2173
|
+
trust = ptmp->trust;
|
2174
|
+
}
|
2175
|
+
if (trust) {
|
2176
|
+
idx = X509_TRUST_get_by_id(trust);
|
2177
|
+
if (idx == -1) {
|
2178
|
+
OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_TRUST_ID);
|
2179
|
+
return 0;
|
2180
|
+
}
|
2181
|
+
}
|
2182
|
+
|
2183
|
+
if (purpose && !ctx->param->purpose)
|
2184
|
+
ctx->param->purpose = purpose;
|
2185
|
+
if (trust && !ctx->param->trust)
|
2186
|
+
ctx->param->trust = trust;
|
2187
|
+
return 1;
|
2244
2188
|
}
|
2245
2189
|
|
2246
2190
|
X509_STORE_CTX *X509_STORE_CTX_new(void)
|
2247
2191
|
{
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
return ctx;
|
2192
|
+
X509_STORE_CTX *ctx;
|
2193
|
+
ctx = (X509_STORE_CTX *)OPENSSL_malloc(sizeof(X509_STORE_CTX));
|
2194
|
+
if (!ctx) {
|
2195
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
2196
|
+
return NULL;
|
2197
|
+
}
|
2198
|
+
memset(ctx, 0, sizeof(X509_STORE_CTX));
|
2199
|
+
return ctx;
|
2257
2200
|
}
|
2258
2201
|
|
2259
2202
|
void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
|
2260
2203
|
{
|
2261
|
-
|
2262
|
-
|
2204
|
+
if (ctx == NULL) {
|
2205
|
+
return;
|
2206
|
+
}
|
2207
|
+
X509_STORE_CTX_cleanup(ctx);
|
2208
|
+
OPENSSL_free(ctx);
|
2263
2209
|
}
|
2264
2210
|
|
2265
2211
|
int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2367
|
-
|
2368
|
-
|
2369
|
-
|
2370
|
-
|
2371
|
-
* This avoids X509_STORE nastiness where it isn't needed.
|
2212
|
+
STACK_OF(X509) *chain)
|
2213
|
+
{
|
2214
|
+
int ret = 1;
|
2215
|
+
|
2216
|
+
memset(ctx, 0, sizeof(X509_STORE_CTX));
|
2217
|
+
ctx->ctx = store;
|
2218
|
+
ctx->cert = x509;
|
2219
|
+
ctx->untrusted = chain;
|
2220
|
+
|
2221
|
+
CRYPTO_new_ex_data(&ctx->ex_data);
|
2222
|
+
|
2223
|
+
ctx->param = X509_VERIFY_PARAM_new();
|
2224
|
+
if (!ctx->param)
|
2225
|
+
goto err;
|
2226
|
+
|
2227
|
+
/*
|
2228
|
+
* Inherit callbacks and flags from X509_STORE if not set use defaults.
|
2229
|
+
*/
|
2230
|
+
|
2231
|
+
if (store)
|
2232
|
+
ret = X509_VERIFY_PARAM_inherit(ctx->param, store->param);
|
2233
|
+
else
|
2234
|
+
ctx->param->inh_flags |= X509_VP_FLAG_DEFAULT | X509_VP_FLAG_ONCE;
|
2235
|
+
|
2236
|
+
if (store) {
|
2237
|
+
ctx->verify_cb = store->verify_cb;
|
2238
|
+
ctx->cleanup = store->cleanup;
|
2239
|
+
} else
|
2240
|
+
ctx->cleanup = 0;
|
2241
|
+
|
2242
|
+
if (ret)
|
2243
|
+
ret = X509_VERIFY_PARAM_inherit(ctx->param,
|
2244
|
+
X509_VERIFY_PARAM_lookup("default"));
|
2245
|
+
|
2246
|
+
if (ret == 0)
|
2247
|
+
goto err;
|
2248
|
+
|
2249
|
+
if (store && store->check_issued)
|
2250
|
+
ctx->check_issued = store->check_issued;
|
2251
|
+
else
|
2252
|
+
ctx->check_issued = check_issued;
|
2253
|
+
|
2254
|
+
if (store && store->get_issuer)
|
2255
|
+
ctx->get_issuer = store->get_issuer;
|
2256
|
+
else
|
2257
|
+
ctx->get_issuer = X509_STORE_CTX_get1_issuer;
|
2258
|
+
|
2259
|
+
if (store && store->verify_cb)
|
2260
|
+
ctx->verify_cb = store->verify_cb;
|
2261
|
+
else
|
2262
|
+
ctx->verify_cb = null_callback;
|
2263
|
+
|
2264
|
+
if (store && store->verify)
|
2265
|
+
ctx->verify = store->verify;
|
2266
|
+
else
|
2267
|
+
ctx->verify = internal_verify;
|
2268
|
+
|
2269
|
+
if (store && store->check_revocation)
|
2270
|
+
ctx->check_revocation = store->check_revocation;
|
2271
|
+
else
|
2272
|
+
ctx->check_revocation = check_revocation;
|
2273
|
+
|
2274
|
+
if (store && store->get_crl)
|
2275
|
+
ctx->get_crl = store->get_crl;
|
2276
|
+
else
|
2277
|
+
ctx->get_crl = NULL;
|
2278
|
+
|
2279
|
+
if (store && store->check_crl)
|
2280
|
+
ctx->check_crl = store->check_crl;
|
2281
|
+
else
|
2282
|
+
ctx->check_crl = check_crl;
|
2283
|
+
|
2284
|
+
if (store && store->cert_crl)
|
2285
|
+
ctx->cert_crl = store->cert_crl;
|
2286
|
+
else
|
2287
|
+
ctx->cert_crl = cert_crl;
|
2288
|
+
|
2289
|
+
if (store && store->lookup_certs)
|
2290
|
+
ctx->lookup_certs = store->lookup_certs;
|
2291
|
+
else
|
2292
|
+
ctx->lookup_certs = X509_STORE_get1_certs;
|
2293
|
+
|
2294
|
+
if (store && store->lookup_crls)
|
2295
|
+
ctx->lookup_crls = store->lookup_crls;
|
2296
|
+
else
|
2297
|
+
ctx->lookup_crls = X509_STORE_get1_crls;
|
2298
|
+
|
2299
|
+
ctx->check_policy = check_policy;
|
2300
|
+
|
2301
|
+
return 1;
|
2302
|
+
|
2303
|
+
err:
|
2304
|
+
CRYPTO_free_ex_data(&g_ex_data_class, ctx, &ctx->ex_data);
|
2305
|
+
if (ctx->param != NULL) {
|
2306
|
+
X509_VERIFY_PARAM_free(ctx->param);
|
2307
|
+
}
|
2308
|
+
|
2309
|
+
memset(ctx, 0, sizeof(X509_STORE_CTX));
|
2310
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
2311
|
+
return 0;
|
2312
|
+
}
|
2313
|
+
|
2314
|
+
/*
|
2315
|
+
* Set alternative lookup method: just a STACK of trusted certificates. This
|
2316
|
+
* avoids X509_STORE nastiness where it isn't needed.
|
2372
2317
|
*/
|
2373
2318
|
|
2374
2319
|
void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
|
2375
2320
|
{
|
2376
|
-
|
2377
|
-
|
2321
|
+
ctx->other_ctx = sk;
|
2322
|
+
ctx->get_issuer = get_issuer_sk;
|
2378
2323
|
}
|
2379
2324
|
|
2380
2325
|
void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx)
|
2381
|
-
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2326
|
+
{
|
2327
|
+
/* We need to be idempotent because, unfortunately, |X509_STORE_CTX_free|
|
2328
|
+
* also calls this function. */
|
2329
|
+
if (ctx->cleanup != NULL) {
|
2330
|
+
ctx->cleanup(ctx);
|
2331
|
+
ctx->cleanup = NULL;
|
2332
|
+
}
|
2333
|
+
if (ctx->param != NULL) {
|
2334
|
+
if (ctx->parent == NULL)
|
2335
|
+
X509_VERIFY_PARAM_free(ctx->param);
|
2336
|
+
ctx->param = NULL;
|
2337
|
+
}
|
2338
|
+
if (ctx->tree != NULL) {
|
2339
|
+
X509_policy_tree_free(ctx->tree);
|
2340
|
+
ctx->tree = NULL;
|
2341
|
+
}
|
2342
|
+
if (ctx->chain != NULL) {
|
2343
|
+
sk_X509_pop_free(ctx->chain, X509_free);
|
2344
|
+
ctx->chain = NULL;
|
2345
|
+
}
|
2346
|
+
CRYPTO_free_ex_data(&g_ex_data_class, ctx, &(ctx->ex_data));
|
2347
|
+
memset(&ctx->ex_data, 0, sizeof(CRYPTO_EX_DATA));
|
2348
|
+
}
|
2402
2349
|
|
2403
2350
|
void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth)
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2351
|
+
{
|
2352
|
+
X509_VERIFY_PARAM_set_depth(ctx->param, depth);
|
2353
|
+
}
|
2407
2354
|
|
2408
2355
|
void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags)
|
2409
|
-
|
2410
|
-
|
2411
|
-
|
2356
|
+
{
|
2357
|
+
X509_VERIFY_PARAM_set_flags(ctx->param, flags);
|
2358
|
+
}
|
2412
2359
|
|
2413
|
-
void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2360
|
+
void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
|
2361
|
+
time_t t)
|
2362
|
+
{
|
2363
|
+
X509_VERIFY_PARAM_set_time(ctx->param, t);
|
2364
|
+
}
|
2417
2365
|
|
2418
2366
|
void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2367
|
+
int (*verify_cb) (int, X509_STORE_CTX *))
|
2368
|
+
{
|
2369
|
+
ctx->verify_cb = verify_cb;
|
2370
|
+
}
|
2423
2371
|
|
2424
2372
|
X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx)
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2373
|
+
{
|
2374
|
+
return ctx->tree;
|
2375
|
+
}
|
2428
2376
|
|
2429
2377
|
int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx)
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2378
|
+
{
|
2379
|
+
return ctx->explicit_policy;
|
2380
|
+
}
|
2433
2381
|
|
2434
2382
|
int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name)
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2383
|
+
{
|
2384
|
+
const X509_VERIFY_PARAM *param;
|
2385
|
+
param = X509_VERIFY_PARAM_lookup(name);
|
2386
|
+
if (!param)
|
2387
|
+
return 0;
|
2388
|
+
return X509_VERIFY_PARAM_inherit(ctx->param, param);
|
2389
|
+
}
|
2442
2390
|
|
2443
2391
|
X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx)
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2392
|
+
{
|
2393
|
+
return ctx->param;
|
2394
|
+
}
|
2447
2395
|
|
2448
2396
|
void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param)
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2397
|
+
{
|
2398
|
+
if (ctx->param)
|
2399
|
+
X509_VERIFY_PARAM_free(ctx->param);
|
2400
|
+
ctx->param = param;
|
2401
|
+
}
|
2454
2402
|
|
2455
2403
|
IMPLEMENT_ASN1_SET_OF(X509)
|
2404
|
+
|
2456
2405
|
IMPLEMENT_ASN1_SET_OF(X509_ATTRIBUTE)
|