Giter Club home page Giter Club logo

Comments (2)

n1ght-hunter avatar n1ght-hunter commented on August 15, 2024

+1
having the exact same problem.

Edit

i found this by following this it fixed it.
https://github.com/sfackler/rust-openssl/pull/535/files

from boring.

ignassew avatar ignassew commented on August 15, 2024

If anyone is struggling with openssl (or boring) not detecting SSL_CERT_FILE while cross-compiling to x86_64-pc-windows-gnu, it's because openssl will use getenv while rust will use SetEnvironmentVariableW which is not compatible (setenv and getenv make a copy at startup which isn't used by SetEnvironmentVariableW).

If you want openssl to read your environment variables, you need to call the C APIs yourself. Here's my code as a reference:

// Licensed under CC0

extern "C" {
    fn putenv(s: *const u8) -> usize;
}

extern "C" {
    fn getenv(s: *const u8) -> *const u8;
}

fn main() {
    unsafe { putenv("SOMETHING=ISUP\0".as_bytes().as_ptr()) };

    // Environment variable is returned to us in a form of a pointer
    let env_ptr = unsafe { getenv("SOMETHING\0".as_bytes().as_ptr()) };
    assert_ne!(env_ptr as usize, 0);
    
    // If we get a null pointer, the environment variable is non existent
    let env_ptr = unsafe { getenv("ELSE\0".as_bytes().as_ptr()) };
    assert_eq!(env_ptr as usize, 0);
}

from boring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.