objective c - NSTask - Respond to input request from OpenSSL -


it seems i'm having trouble understanding nstask in cocoa. application want launch openssl. currently, i'm able send information (launch path, arguments etc.) , can response using nspipe. need able though respond input requests application asks for. following code, can send , read response file:

 nstask *task; task = [[nstask alloc] init]; [task setlaunchpath: launchpath]; [task setarguments: arguments]; [task setcurrentdirectorypath:dir];  nspipe *pipe; pipe = [nspipe pipe]; [task setstandardoutput: pipe];  nsfilehandle *file; file = [pipe filehandleforreading];  [task launch];  nsdata *data; data = [file readdatatoendoffile]; nsstring *response =  [[nsstring alloc] initwithdata: data encoding: nsutf8stringencoding]; 

once launch nstask, i'm expected provide things domain name, country etc. reason question because need able generate certificate signing request openssl , send it, along other data, on server. code above not broken, i'm not sure how can go sending on input.

also, if has used sort of openssl implementation cocoa/objc , feels better option using nstask, i'm open well.

thanks in advance.

not looking @ this, if , didn't know answer, found solution ended using different method. instead of sending additional input, pass -subj parameter. however, solution asking follows:

nstask *task = [[nstask alloc] init];  nsstring *tmpdir=nstemporarydirectory(); [task setcurrentdirectorypath:tmpdir];  [task setlaunchpath:@"/usr/bin/openssl"]; nsarray *sslarguments=@[@"req",@"-nodes",@"-newkey",@"rsa:2048",@"-keyout",@"myserver.key",@"-out",@"server.csr"]; [task setarguments:sslarguments];   nspipe * in = [nspipe pipe];  [task setstandardinput:in];  nsdata *data=[@"gb\nyorks\n\nyork\simuplansl\nit\nsomeone@simuplan.com" datausingencoding:nsutf8stringencoding];  [task launch]; [[in filehandleforwriting] writedata:data]; [task waituntilexit]; 

i had write file in temporary directory , feed through input pipe.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -