%args> $pkcs10 => undef $role => undef $profile => undef %args> <%init> # protect against XSRF by checking for $__session_id (see # /service/workflow/activity/autohandler for details) if (! $m->request_args()->{'__session_id'}) { #die "This looks like XSRF to me ..."; } use Data::Dumper; my @requests; my @lines = split /\n/, $pkcs10; my $i = -1; my $stop = 1; # parse request text and add the requests to the @requests array foreach my $line (@lines) { if ($line =~ m{-----BEGIN\ CERTIFICATE\ REQUEST-----}xms) { $i++; $stop = 0; } if ($i >= 0 && ! $stop) { $requests[$i] .= $line . "\n"; } if ($line =~ m{-----END\ CERTIFICATE\ REQUEST-----}xms) { $stop = 1; } } # get the bulk subject style for this profile my $msg = $context->{client}->send_receive_command_msg( 'get_cert_subject_styles', { PROFILE => $profile, }, ); my $subject_style; if (ref $msg->{PARAMS} eq 'HASH') { SUBJ_STYLE: foreach my $key (keys %{ $msg->{PARAMS} }) { if (exists $msg->{PARAMS}->{$key}->{BULK}) { $subject_style = $key; last SUBJ_STYLE; } } } # TODO - error handling (if (! defined $subject_style)) my $ser = OpenXPKI::Serialization::Simple->new(); my @results; REQUEST: for (my $i = 0; $i < scalar @requests; $i++) { my $request = $requests[$i]; my %cert_subject_parts; my $msg = $context->{'client'}->send_receive_command_msg( 'get_cert_subject_styles', { PROFILE => $profile, PKCS10 => $request, } ); if (exists $msg->{SERVICE_MSG} && $msg->{SERVICE_MSG} eq 'ERROR') { $results[$i]->{ERRORS} = $msg; next REQUEST; } my @input = @{ $msg->{PARAMS}->{$subject_style}->{TEMPLATE}->{INPUT} }; foreach my $entry (@input) { $cert_subject_parts{'cert_subject_' . $entry->{ID}} = $entry->{DEFAULT} } # TODO - SANs, error handling $msg = $context->{'client'}->send_receive_command_msg( 'create_workflow_instance', { WORKFLOW => 'I18N_OPENXPKI_WF_TYPE_CERTIFICATE_SIGNING_REQUEST', PARAMS => { 'cert_info' => $ser->serialize({}), 'cert_subject_parts' => $ser->serialize(\%cert_subject_parts), 'cert_subject_alt_name_parts' => $ser->serialize({}), 'cert_profile' => $profile, 'cert_role' => $role, 'cert_subject_style' => $subject_style, 'pkcs10' => $request, 'csr_type' => 'pkcs10', 'bulk' => '1', }, } ); if (exists $msg->{SERVICE_MSG} && $msg->{SERVICE_MSG} eq 'ERROR') { $results[$i]->{ERRORS} = $msg; } else { $results[$i]->{SUBJECT} = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{cert_subject}; $results[$i]->{ID} = $msg->{PARAMS}->{WORKFLOW}->{ID}; } } %init>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_BULK_RESULTS_DESC') %>
<% $i %> | % if (exists $result->{ERRORS}) {<% i18nGettext('I18N_OPENXPKI_ERROR') %> | % my @errors = $m->comp('/lib/get_deep_error.mhtml', 'msg' => $result->{ERRORS} ); <& /service/create_csr/print_errors.mhtml, 'errors' => \@errors, no_title => 1 &> | % } % else {<% i18nGettext('I18N_OPENXPKI_SUCCESS') %> | <% $result->{ID} %>: <% $result->{SUBJECT} %> | % }