Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Backup pfSense via PHP + cURL

    Scheduled Pinned Locked Moved Off-Topic & Non-Support Discussion
    1 Posts 1 Posters 989 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      andresense
      last edited by

      I'm trying to hold up the pfSense through php + curl lib. But it reports the following error:

      CSRF check failed. Your form session may have expired, or you may not have cookies enabled.

      Code:

      $camposPost = array (  'usernamefld' => 'admin', 'passwordfld' => 'password');

      $ch = curl_init();

      curl_setopt($ch, CURLOPT_URL, 'https://pfsense');
      curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
      curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');

      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
      curl_setopt($ch, CURLOPT_COOKIESESSION, true);
      curl_setopt($ch, CURLOPT_POST, true );
      curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldPost);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:  "));

      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

      curl_exec($ch);

      curl_close($ch);

      ?>

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.