I think that the stream that it writes to is platform specific.

The default implementation for ui_write_string is in ui_openssl.c:

static int write_string(UI *ui, UI_STRING *uis)
    {
    switch (UI_get_string_type(uis))
        {
    case UIT_ERROR:
    case UIT_INFO:
        fputs(UI_get0_output_string(uis), tty_out);
        fflush(tty_out);
        break;
    default:
        break;
        }
    return 1;
    }

This writes to "tty_out". This is set in open_console, also in ui_openssl.c:
#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS)
    tty_in=stdin;
    tty_out=stderr;
#else
#  ifdef OPENSSL_SYS_MSDOS
#    define DEV_TTY "con"
#  else
#    define DEV_TTY "/dev/tty"
#  endif
    if ((tty_in=fopen(DEV_TTY,"r")) == NULL)
        tty_in=stdin;
    if ((tty_out=fopen(DEV_TTY,"w")) == NULL)
        tty_out=stderr;

So depending on your platform it will be one of stderr, con or /dev/tty. Since you said you've attempted to redirect the output for stdout and stderr already, I'm guessing that for you it is writing direct to /dev/tty.


Hope that helps.

Matt



On 26/01/12 22:29, Robert O'Hearne wrote:
I am using a Java program to call a Perl script which calls curl to upload a file to a 
FTPS server.  The FTPS server has a certificate which requires a pass phrase.  My Java 
program reads from standard error looking for the "Enter PEM pass phrase:" 
prompt so I can then write the pass phrase to stdin.

The problem is the "Enter PEM pass phrase:" prompt is not present in standard error or 
standard out.  For example: from the Linux (Red Hat Enterprise 5.1) bash shell prompt, I call curl 
and redirect standard error and standard output to files. The "Enter PEM pass phrase:" 
prompt still appears at the console, and is not present in either of the redirect files.

I am trying to understand how OpenSSL writes this prompt, especially to what stream 
it writes it.  I believe curl is calling SSL_CTX_use_certificate_chain_file which 
issues the prompt, but I am not certain about that.  I do see the prompt in pem_lib.c 
method PEM_def_callback. The prompt is written in ui_lib.c method UI_process, in the 
call ui->meth->ui_write_string.  At this point I don't understand what happens. 
I am not a C programmer.

My ultimate problem is how to capture the "Enter PEM pass phrase:" prompt from a Java 
program as described above.  But my question for this list is, please explain how the "Enter 
PEM pass phrase:" prompt is written, including where is the code which actually writes.

Thanks

Robert O'Hearne



                                          
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to