+#ifdef ENABLE_VPNCONTROL_PORT
+static void
+isakmp_info_vpncontrol_notify_ike_failed (phase1_handle_t *iph1, int isakmp_info_initiator, int type, vchar_t *data)
+{
+ u_int32_t address = iph1_get_remote_v4_address(iph1);
+ u_int32_t fail_reason;
+
+ /* notify the API that we have received the delete */
+
+ if (isakmp_info_initiator == FROM_REMOTE) {
+ int premature = oakley_find_status_in_certchain(iph1->cert, CERT_STATUS_PREMATURE);
+ int expired = oakley_find_status_in_certchain(iph1->cert, CERT_STATUS_EXPIRED);
+
+ if (premature) {
+ fail_reason = VPNCTL_NTYPE_LOCAL_CERT_PREMATURE;
+ plog(ASL_LEVEL_NOTICE, ">>> Server reports client's certificate is pre-mature\n");
+ } else if (expired) {
+ fail_reason = VPNCTL_NTYPE_LOCAL_CERT_EXPIRED;
+ plog(ASL_LEVEL_NOTICE, ">>> Server reports client's certificate is expired\n");
+ } else {
+ fail_reason = type;
+ }
+ vpncontrol_notify_ike_failed(fail_reason, isakmp_info_initiator, address, 0, NULL);
+ return;
+ } else {
+ /* FROM_LOCAL */
+ if (type == ISAKMP_INTERNAL_ERROR ||
+ type <= ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS) {
+ int premature = oakley_find_status_in_certchain(iph1->cert_p, CERT_STATUS_PREMATURE);
+ int expired = oakley_find_status_in_certchain(iph1->cert_p, CERT_STATUS_EXPIRED);
+ int subjname = oakley_find_status_in_certchain(iph1->cert_p, CERT_STATUS_INVALID_SUBJNAME);
+ int subjaltname = oakley_find_status_in_certchain(iph1->cert_p, CERT_STATUS_INVALID_SUBJALTNAME);
+
+ if (premature) {
+ fail_reason = VPNCTL_NTYPE_PEER_CERT_PREMATURE;
+ plog(ASL_LEVEL_NOTICE, ">>> Server's certificate is pre-mature\n");
+ } else if (expired) {
+ fail_reason = VPNCTL_NTYPE_PEER_CERT_EXPIRED;
+ plog(ASL_LEVEL_NOTICE, ">>> Server's certificate is expired\n");
+ } else if (subjname) {
+ fail_reason = VPNCTL_NTYPE_PEER_CERT_INVALID_SUBJNAME;
+ plog(ASL_LEVEL_NOTICE, ">>> Server's certificate subject name not valid\n");
+ } else if (subjaltname) {
+ fail_reason = VPNCTL_NTYPE_PEER_CERT_INVALID_SUBJALTNAME;
+ plog(ASL_LEVEL_NOTICE, ">>> Server's certificate subject alternate name not valid\n");
+ } else {
+ fail_reason = type;
+ }
+ (void)vpncontrol_notify_ike_failed(fail_reason, isakmp_info_initiator, address,
+ (data ? data->l : 0), (u_int8_t *)(data ? data->v : NULL));
+ return;
+ }
+ }
+}
+#endif /* ENABLE_VPNCONTROL_PORT */
+