@@ -349,15 +349,6 @@ internal static PathFile SplitStorePathFile(string pathFileName)
349349 }
350350 }
351351
352- internal string GenerateCSROnDevice ( string subjectText , bool overwrite , string alias , SupportedKeyTypeEnum keyType , int keySize , Dictionary < string , string [ ] > sans , out AsymmetricAlgorithm privateKey )
353- {
354- string csr = string . Empty ;
355- privateKey = RSA . Create ( ) ;
356-
357-
358- return csr ;
359- }
360-
361352 internal string GenerateCSR ( string subjectText , bool overwrite , string alias , SupportedKeyTypeEnum keyType , int keySize , Dictionary < string , string [ ] > sans , out AsymmetricAlgorithm privateKey )
362353 {
363354 if ( CertificateStore . ContainsAlias ( alias ) && ! overwrite )
@@ -379,69 +370,6 @@ internal string GenerateCSR(string subjectText, bool overwrite, string alias, Su
379370 return csr ;
380371 }
381372
382- internal string GenerateCSROnDevice ( string subjectText , bool overwrite , string alias , SupportedKeyTypeEnum keyType , int keySize , Dictionary < string , string [ ] > sans , out AsymmetricAlgorithm privateKey )
383- {
384- string path = ApplicationSettings . TempFilePathForODKG ;
385- if ( path . Substring ( path . Length - 1 , 1 ) != "/" ) path += "/" ;
386- string fileName = Guid . NewGuid ( ) . ToString ( ) ;
387-
388- System . Security . Cryptography . X509Certificates . X500DistinguishedName dn = new System . Security . Cryptography . X509Certificates . X500DistinguishedName ( subjectText ) ;
389- string opensslSubject = dn . Format ( true ) . Replace ( "S=" , "ST=" ) ;
390- opensslSubject = opensslSubject . Replace ( System . Environment . NewLine , "/" ) ;
391- opensslSubject = "/" + opensslSubject . Substring ( 0 , opensslSubject . Length - 1 ) ;
392-
393- string cmd = $ "openssl req -new -newkey REPLACE -nodes -keyout { path } { fileName } .key -out { path } { fileName } .csr -subj '{ opensslSubject } '";
394- switch ( keyType )
395- {
396- case SupportedKeyTypeEnum . RSA :
397- cmd = cmd . Replace ( "REPLACE" , $ "rsa:{ keySize . ToString ( ) } ") ;
398- break ;
399- case SupportedKeyTypeEnum . ECC :
400- string algName = "prime256v1" ;
401- switch ( keySize )
402- {
403- case 384 :
404- algName = "secp384r1" ;
405- break ;
406- case 521 :
407- algName = "secp521r1" ;
408- break ;
409- }
410- cmd = cmd . Replace ( "REPLACE" , $ "ec:<(openssl ecparam -name { algName } )") ;
411- break ;
412- }
413-
414- string csr = string . Empty ;
415-
416- try
417- {
418- try
419- {
420- RemoteHandler . RunCommand ( cmd , null , ApplicationSettings . UseSudo , null ) ;
421- }
422- catch ( Exception ex )
423- {
424- if ( ! ex . Message . Contains ( "----" ) )
425- throw ;
426- }
427-
428- string privateKeyString = Encoding . UTF8 . GetString ( RemoteHandler . DownloadCertificateFile ( path + fileName + ".key" ) ) ;
429- privateKey = keyType == SupportedKeyTypeEnum . RSA ? RSA . Create ( ) : ECDsa . Create ( ) ;
430- privateKey . ImportFromPem ( privateKeyString ) ;
431-
432- csr = Encoding . UTF8 . GetString ( RemoteHandler . DownloadCertificateFile ( path + fileName + ".csr" ) ) ;
433- }
434- finally
435- {
436- if ( RemoteHandler . DoesFileExist ( path + fileName + ".key" ) )
437- RemoteHandler . RemoveCertificateFile ( path , fileName + ".key" ) ;
438- if ( RemoteHandler . DoesFileExist ( path + fileName + ".csr" ) )
439- RemoteHandler . RemoveCertificateFile ( path , fileName + ".csr" ) ;
440- }
441-
442- return csr ;
443- }
444-
445373 internal void Initialize ( string sudoImpersonatedUser , bool useShellCommands )
446374 {
447375 logger . MethodEntry ( LogLevel . Debug ) ;
0 commit comments