Module: Yast::CaManagementSignRequestInclude

Defined in:
../../src/include/ca-management/signRequest.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) createExtentionItem

Creates Request Extention items

Returns:

  • a list items formated for a UI Multiselectionbox



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File '../../src/include/ca-management/signRequest.rb', line 125

def createExtentionItem
  requestMap = Convert.to_map(
    YaPI::CaManagement.ReadRequest(
      {
        "caName"   => CaMgm.currentCA,
        "caPasswd" => getPassword(CaMgm.currentCA),
        "request"  => CaMgm.currentRequest,
        "type"     => "parsed"
      }
    )
  )

  opensslExtentions = Ops.get_map(requestMap, "OPENSSL_EXTENSIONS", {})
  result = []
  Builtins.foreach(CaMgm.requestExtentionValue) do |key, value|
    if key != "certificatePolicies"
      # this key will be ignored
      result = Builtins.add(
        result,
        Item(
          Id(key),
          Ops.add(
            Ops.add(Ops.get_string(value, "description", ""), ": "),
            Builtins.mergestring(
              Convert.convert(
                Ops.get(
                  opensslExtentions,
                  Ops.get_string(value, "description", ""),
                  []
                ),
                :from => "list",
                :to   => "list <string>"
              ),
              " "
            )
          ),
          Builtins.contains(CaMgm.slectedRequestExtention, key)
        )
      )
    else
      Builtins.y2milestone("Ignoring certificatePolicies")
    end
  end
  deep_copy(result)
end

- (Object) getRequestDescription(requestMap, onlySubject)

getRequestDescription - description of a request

Parameters:

  • map

    of description, onlySubject

Returns:

  • a string with the request description



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File '../../src/include/ca-management/signRequest.rb', line 53

def getRequestDescription(requestMap, onlySubject)
  requestMap = deep_copy(requestMap)
  text = _("<p><b>Description</b></p>")
  if requestMap == nil
    showErrorCaManagement
    return _("\nRequest not found.\n")
  end
  text = Ops.add(text, "<pre>")
  dn = Ops.get_map(requestMap, "SUBJECT_HASH", {})
  if Ops.greater_than(Builtins.size(dn), 0)
    text = Ops.add(
      Ops.add(text, "\nCommon Name:        "),
      Ops.get_string(Ops.get_list(dn, "CN", []), 0, "")
    )
    if Ops.greater_than(
        Builtins.size(Ops.get_string(requestMap, "date", "")),
        0
      )
      text = Ops.add(
        Ops.add(text, "\ngeneration Time:    "),
        Ops.get_string(requestMap, "date", "")
      )
    end
    text = Ops.add(
      Ops.add(text, "\nOrganization:       "),
      Ops.get_string(Ops.get_list(dn, "O", []), 0, "")
    )
    text = Ops.add(
      Ops.add(text, "\nLocation:           "),
      Ops.get_string(Ops.get_list(dn, "L", []), 0, "")
    )
    text = Ops.add(
      Ops.add(text, "\nState:              "),
      Ops.get_string(Ops.get_list(dn, "ST", []), 0, "")
    )
    text = Ops.add(
      Ops.add(text, "\nCountry:            "),
      Ops.get_string(Ops.get_list(dn, "C", []), 0, "")
    )
    text = Ops.add(
      Ops.add(text, "\nEMAIL:              "),
      Ops.get_string(Ops.get_list(dn, "emailAddress", []), 0, "")
    )
  end
  if !onlySubject
    text = Ops.add(
      Ops.add(text, "\nIs CA:              "),
      Ops.get_string(requestMap, "IS_CA", "")
    )
    text = Ops.add(
      Ops.add(text, "\nKey Size:           "),
      Ops.get_string(requestMap, "KEYSIZE", "")
    )
    text = Ops.add(
      Ops.add(text, "\nVersion:            "),
      Ops.get_string(requestMap, "VERSION", "")
    )
    text = Ops.add(
      Ops.add(text, "\nalgo. of pub. Key : "),
      Ops.get_string(requestMap, "PUBKEY_ALGORITHM", "")
    )
    text = Ops.add(
      Ops.add(text, "\nalgo. of signature: "),
      Ops.get_string(requestMap, "SIGNATURE_ALGORITHM", "")
    )
  end
  text = Ops.add(text, "</pre>")
  text
end

- (Object) initialize_ca_management_signRequest(include_target)



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File '../../src/include/ca-management/signRequest.rb', line 34

def initialize_ca_management_signRequest(include_target)
  textdomain "ca-management"

  Yast.import "CaMgm"
  Yast.import "Wizard"
  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "YaPI::CaManagement"

  Yast.include include_target, "ca-management/util.rb"
  Yast.include include_target, "ca-management/new_cert_read_write.rb"

  # Description of the current Request
  @currentRequestMap = {}
end

- (Object) setExtentionValues(acceptedExtentions)

setExtentionValues - Accept special extention values

Parameters:

  • list

    of accepted extentions



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File '../../src/include/ca-management/signRequest.rb', line 578

def setExtentionValues(acceptedExtentions)
  acceptedExtentions = deep_copy(acceptedExtentions)
  Builtins.foreach(acceptedExtentions) do |extention|
    # setting all accepted extentions
    setRequestExtentions(extention)
  end

  Builtins.foreach(CaMgm.slectedRequestExtention) do |extention|
    if !Builtins.contains(acceptedExtentions, extention)
      #set to defaults
      unsetRequestExtentions(extention)
    end
  end

  CaMgm.slectedRequestExtention = deep_copy(acceptedExtentions)

  nil
end

- (void) setRequestExtentions(extention)

This method returns an undefined value.

The user has decide that given request extention will be used. --> setting for signation

Parameters:

  • request

    extention



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
# File '../../src/include/ca-management/signRequest.rb', line 256

def setRequestExtentions(extention)
  Builtins.y2milestone("Set requestExtention %1", extention)
  Builtins.y2milestone(
    "requestExtention %1",
    Ops.get(CaMgm.requestExtentionValue, extention, {})
  )

  extMap = Ops.get(CaMgm.requestExtentionValue, extention, {})

  if extention == "subjectKeyIdentifier"
    CaMgm.exp_cri_subjectKeyIdentifier = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.exp_subjectKeyIdentifier = ""
    counter = 0

    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      if counter == 0
        CaMgm.exp_subjectKeyIdentifier = Ops.add(
          CaMgm.exp_subjectKeyIdentifier,
          entry
        )
      else
        CaMgm.exp_subjectKeyIdentifier = Ops.add(
          Ops.add(CaMgm.exp_subjectKeyIdentifier, ","),
          entry
        )
      end
      counter = Ops.add(counter, 1)
    end
  elsif extention == "subjectAltName"
    CaMgm.adv_subject_alt_name_list = []
    CaMgm.adv_cri_subject_alt_name = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.adv_copy_subject_alt_name = false

    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      new_entry = {}
      Ops.set(new_entry, "kind", Ops.get_string(entry, "type", ""))
      Ops.set(new_entry, "name", Ops.get_string(entry, "value", ""))
      CaMgm.adv_subject_alt_name_list = Builtins.add(
        CaMgm.adv_subject_alt_name_list,
        new_entry
      )
    end
  elsif extention == "basicConstraints"
    CaMgm.adv_cri_ca = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.adv_ca = ""

    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      if Ops.get_string(entry, "value", "") == "false" ||
          Ops.get_string(entry, "value", "") == "FALSE"
        CaMgm.adv_ca = Ops.add(Ops.get_string(entry, "type", ""), ":false")
      else
        CaMgm.adv_ca = Ops.add(Ops.get_string(entry, "type", ""), ":true")
      end
    end
  elsif extention == "keyUsage"
    CaMgm.adv_cri_key_usage = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.adv_digitalSignature = false
    CaMgm.adv_nonRepudiation = false
    CaMgm.adv_cRLSign = false
    CaMgm.adv_keyEncipherment = false
    CaMgm.adv_dataEncipherment = false
    CaMgm.adv_encipherOnly = false
    CaMgm.adv_keyAgreement = false
    CaMgm.adv_keyCertSign = false
    CaMgm.adv_decipherOnly = false

    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      if entry == "digitalSignature"
        CaMgm.adv_digitalSignature = true
      elsif entry == "nonRepudiation"
        CaMgm.adv_nonRepudiation = true
      elsif entry == "cRLSign"
        CaMgm.adv_cRLSign = true
      elsif entry == "keyEncipherment"
        CaMgm.adv_keyEncipherment = true
      elsif entry == "dataEncipherment"
        CaMgm.adv_dataEncipherment = true
      elsif entry == "encipherOnly"
        CaMgm.adv_encipherOnly = true
      elsif entry == "keyAgreement"
        CaMgm.adv_keyAgreement = true
      elsif entry == "keyCertSign"
        CaMgm.adv_keyCertSign = true
      elsif entry == "decipherOnly"
        CaMgm.adv_decipherOnly = true
      end
    end
  elsif extention == "extendedKeyUsage"
    CaMgm.exp_cri_extendedKeyUsage = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.exp_extendedKeyUsage = ""

    counter = 0
    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      if entry == "TLS Web Server Authentication"
        entry = "serverAuth"
      elsif entry == "TLS Web Client Authentication"
        entry = "clientAuth"
      elsif entry == "Code signing"
        entry = "codeSigning"
      elsif entry == "E-mail Protection"
        entry = "emailProtection"
      elsif entry == "Time Stamping"
        entry = "timeStamping"
      elsif entry == "Microsoft Individual Code Signing"
        entry = "msCodeInd"
      elsif entry == "Microsoft Commercial Code Signing"
        entry = "msCodeCom"
      elsif entry == "Microsoft Trust List Signing"
        entry = "msCTLSign"
      elsif entry == "Microsoft Server Gated Crypto"
        entry = "msSGC"
      elsif entry == "Microsoft Encrypted File System"
        entry = "msEFS"
      elsif entry == "Netscape Server Gated Crypto"
        entry = "nsSGC"
      elsif entry == "Microsoft Smartcardlogin"
        entry = "msSmartcardLogin"
      end
      if counter == 0
        CaMgm.exp_extendedKeyUsage = Ops.add(
          CaMgm.exp_extendedKeyUsage,
          entry
        )
      else
        CaMgm.exp_extendedKeyUsage = Ops.add(
          Ops.add(CaMgm.exp_extendedKeyUsage, ","),
          entry
        )
      end
      counter = Ops.add(counter, 1)
    end
  elsif extention == "nsComment"
    CaMgm.adv_cri_nsComment = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.adv_nsComment = Ops.get_string(extMap, "value", "")
  elsif extention == "authorityKeyIdentifier"
    CaMgm.exp_cri_authorityKeyIdentifier = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.exp_authorityKeyIdentifier = ""

    counter = 0
    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      if counter == 0
        CaMgm.exp_authorityKeyIdentifier = Ops.add(
          Ops.add(
            Ops.add(
              CaMgm.exp_authorityKeyIdentifier,
              Ops.get_string(entry, "type", "")
            ),
            Ops.greater_than(
              Builtins.size(Ops.get_string(entry, "value", "")),
              0
            ) ? ":" : ""
          ),
          Ops.get_string(entry, "value", "")
        )
      else
        CaMgm.exp_authorityKeyIdentifier = Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(CaMgm.exp_authorityKeyIdentifier, ","),
              Ops.get_string(entry, "type", "")
            ),
            Ops.greater_than(
              Builtins.size(Ops.get_string(entry, "value", "")),
              0
            ) ? ":" : ""
          ),
          Ops.get_string(entry, "value", "")
        )
      end
      counter = Ops.add(counter, 1)
    end
    CaMgm.exp_authorityKeyIdentifier = strip(
      CaMgm.exp_authorityKeyIdentifier
    )
  elsif extention == "nsCertType"
    CaMgm.adv_cri_nsCertType = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.adv_client = false
    CaMgm.adv_server = false
    CaMgm.adv_sslCA = false
    CaMgm.adv_email = false
    CaMgm.adv_reserved = false
    CaMgm.adv_emailCA = false
    CaMgm.adv_objsign = false
    CaMgm.adv_objCA = false

    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      if entry == "client"
        CaMgm.adv_client = true
      elsif entry == "server"
        CaMgm.adv_server = true
      elsif entry == "sslCA"
        CaMgm.adv_sslCA = true
      elsif entry == "email"
        CaMgm.adv_email = true
      elsif entry == "reserved"
        CaMgm.adv_reserved = true
      elsif entry == "emailCA"
        CaMgm.adv_emailCA = true
      elsif entry == "objsign"
        CaMgm.adv_objsign = true
      elsif entry == "objCA"
        CaMgm.adv_objCA = true
      end
    end
  elsif extention == "nsCaRevocationUrl"
    CaMgm.exp_cri_netscape_nsCaRevocationUrl = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.exp_netscape_nsCaRevocationUrl = Ops.get_string(
      extMap,
      "value",
      ""
    )
  elsif extention == "nsCaPolicyUrl"
    CaMgm.exp_cri_netscape_nsCaPolicyUrl = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.exp_netscape_nsCaPolicyUrl = Ops.get_string(extMap, "value", "")
  elsif extention == "nsBaseUrl"
    CaMgm.exp_cri_netscape_nsBaseUrl = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.exp_netscape_nsBaseUrl = Ops.get_string(extMap, "value", "")
  elsif extention == "nsRenewalUrl"
    CaMgm.exp_cri_netscape_nsRenewalUrl = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.exp_netscape_nsRenewalUrl = Ops.get_string(extMap, "value", "")
  elsif extention == "nsRevocationUrl"
    CaMgm.exp_cri_netscape_nsRevocationUrl = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.exp_netscape_nsRevocationUrl = Ops.get_string(extMap, "value", "")
  elsif extention == "nsSslServerName"
    CaMgm.adv_cri_nsSslServerName = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.adv_nsSslServerName = Ops.get_string(extMap, "value", "")
  elsif extention == "issuserAltName"
    CaMgm.adv_issuer_alt_name_list = []
    CaMgm.adv_cri_issuer_alt_name = Ops.get_string(extMap, "critical", "0") == "1"
    CaMgm.adv_copy_subject_alt_name = false

    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      new_entry = {}
      Ops.set(new_entry, "kind", Ops.get_string(entry, "type", ""))
      Ops.set(new_entry, "name", Ops.get_string(entry, "value", ""))
      CaMgm.adv_issuer_alt_name_list = Builtins.add(
        CaMgm.adv_issuer_alt_name_list,
        new_entry
      )
    end
  elsif extention == "crlDistributionPoints"
    CaMgm.adv_cri_distribution_point = Ops.get_string(
      extMap,
      "critical",
      "0"
    ) == "1"
    CaMgm.adv_distribution_point = ""
    counter = 0

    Builtins.foreach(Ops.get_list(extMap, "value", [])) do |entry|
      if counter == 0
        CaMgm.adv_distribution_point = Ops.add(
          Ops.add(
            Ops.add(
              CaMgm.adv_distribution_point,
              Ops.get_string(entry, "type", "")
            ),
            Ops.greater_than(
              Builtins.size(Ops.get_string(entry, "value", "")),
              0
            ) ? ":" : ""
          ),
          Ops.get_string(entry, "value", "")
        )
      else
        CaMgm.adv_distribution_point = Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(CaMgm.adv_distribution_point, ","),
              Ops.get_string(entry, "type", "")
            ),
            Ops.greater_than(
              Builtins.size(Ops.get_string(entry, "value", "")),
              0
            ) ? ":" : ""
          ),
          Ops.get_string(entry, "value", "")
        )
      end
      counter = Ops.add(counter, 1)
    end
  elsif extention == "certificatePolicies"
    Builtins.y2milestone("certificatePolicies ignored")
  else
    Popup.Error(
      Builtins.sformat(_("Extension \"%1\" not found."), extention)
    )
  end

  nil
end

- (Object) signRequest1(kind)

Signing a request ( 1. step )

Parameters:

  • kind (String)

    (“Client Request”,“Server Request”,“CA Request”)

Returns:

  • `next, 'abort



688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
# File '../../src/include/ca-management/signRequest.rb', line 688

def signRequest1(kind)
  helptext = ""
  # help text 1/3
  helptext = _("<p>This frame shows the signing request.</p>")

  # help text 2/3
  helptext = Ops.add(
    helptext,
    _(
      "<p>The request has special request extensions, which you can accept.</p>"
    )
  )
  # help text 3/3
  helptext = Ops.add(
    helptext,
    _(
      "<p>If you reject these extensions, the default values are taken instead.</p>"
    )
  )

  contents = VBox(
    RichText(getRequestDescription(@currentRequestMap, true)),
    IntField(
      Id(:period),
      _("&Valid Period (days):"),
      1,
      10000,
      CaMgm.validPeriod
    ),
    MultiSelectionBox(
      Id(:extentions),
      _("Requested Extensions"),
      createExtentionItem
    )
  )

  Wizard.SetContents(
    Builtins.sformat(_("Sign Request as a %1 (Step 1/2)"), kind),
    contents,
    helptext,
    true,
    true
  )
  Wizard.RestoreNextButton
  Wizard.DisableBackButton
  UI.SetFocus(Id(:period))

  ui = nil
  begin
    ui = Convert.to_symbol(UI.UserInput)

    if ui == :next
      CaMgm.validPeriod = Convert.to_integer(
        UI.QueryWidget(Id(:period), :Value)
      )
      setExtentionValues(
        Convert.convert(
          UI.QueryWidget(Id(:extentions), :SelectedItems),
          :from => "any",
          :to   => "list <string>"
        )
      )
    end
  end until Builtins.contains([:next, :abort], ui)

  ui
end

- (Object) signRequest2(kind)

Signing request ( 2. step )

Parameters:

  • kind (String)

    (“Client Request”,“Server Request”,“CA Request”)

Returns:

  • next, 'back, 'cancel,advancedOptions



760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
# File '../../src/include/ca-management/signRequest.rb', line 760

def signRequest2(kind)
  i = 0
  nextLine = false

  # help text 1/2
  helptext = _(
    "<p>This frame gives an overview of all settings for the request that will be signed.</p>"
  )
  # help text 2/2
  helptext = Ops.add(
    helptext,
    _("<p>Click <b>Sign Request</b> to go on.</p>")
  )

  text = _("<p><b>Summary</b></p>")
  text = Ops.add(text, "<br><pre>")
  text = Ops.add(
    Ops.add(
      Ops.add(text, "Subject:                  "),
      CaMgm.requestSubject
    ),
    "\n"
  )
  text = Ops.add(
    Ops.add(
      Ops.add(
        Ops.add(text, "Valid Period:             "),
        CaMgm.validPeriod
      ),
      _(" days")
    ),
    "\n"
  )
  text = Ops.add(
    Ops.add(Ops.add(text, "<p>Basic Constaints:         "), CaMgm.adv_ca),
    CaMgm.adv_cri_ca ? _(" (critical)</p>") : "</p>"
  )
  if CaMgm.adv_pathlen
    text = Ops.add(
      Ops.add(
        Ops.add(
          Ops.add(text, "                          "),
          _("Path Length ")
        ),
        CaMgm.adv_pathlenValue
      ),
      "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.adv_nsComment), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, _("nsComment:                ")),
        CaMgm.adv_nsComment
      ),
      CaMgm.adv_cri_nsComment ? _(" (critical)\n") : "\n"
    )
  end
  if CaMgm.adv_client || CaMgm.adv_server || CaMgm.adv_sslCA ||
      CaMgm.adv_email ||
      CaMgm.adv_reserved ||
      CaMgm.adv_emailCA ||
      CaMgm.adv_objsign ||
      CaMgm.adv_objCA
    text = Ops.add(
      Ops.add(text, _("nsCertType:               ")),
      CaMgm.adv_cri_nsCertType ? _(" (critical)\n") : ""
    )
    nextLine = CaMgm.adv_cri_nsCertType
    if CaMgm.adv_client
      if !nextLine
        nextLine = true
        text = Ops.add(text, "client\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "client\n"
        )
      end
    end
    if CaMgm.adv_server
      if !nextLine
        nextLine = true
        text = Ops.add(text, "server\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "server\n"
        )
      end
    end
    if CaMgm.adv_sslCA
      if !nextLine
        nextLine = true
        text = Ops.add(text, "sslCA\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "sslCA\n"
        )
      end
    end
    if CaMgm.adv_email
      if !nextLine
        nextLine = true
        text = Ops.add(text, "email\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "email\n"
        )
      end
    end
    if CaMgm.adv_reserved
      if !nextLine
        nextLine = true
        text = Ops.add(text, "reserved\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "reserved\n"
        )
      end
    end

    if CaMgm.adv_emailCA
      if !nextLine
        nextLine = true
        text = Ops.add(text, "emailCA\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "emailCA\n"
        )
      end
    end
    if CaMgm.adv_objsign
      if !nextLine
        nextLine = true
        text = Ops.add(text, "objsign\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "objsign\n"
        )
      end
    end
    if CaMgm.adv_objCA
      if !nextLine
        nextLine = true
        text = Ops.add(text, "objCA\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "objCA\n"
        )
      end
    end
    if !nextLine
      nextLine = true
      text = Ops.add(text, "\n")
    end
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_extendedKeyUsage), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "extendedKeyUsage:         "),
        CaMgm.exp_extendedKeyUsage
      ),
      CaMgm.exp_cri_extendedKeyUsage ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_subjectKeyIdentifier), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "Subject Key Identifier:   "),
        CaMgm.exp_subjectKeyIdentifier
      ),
      CaMgm.exp_cri_subjectKeyIdentifier ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_authorityKeyIdentifier), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "Authority Key Identifier: "),
        CaMgm.exp_authorityKeyIdentifier
      ),
      CaMgm.exp_cri_authorityKeyIdentifier ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.adv_subject_alt_name_list), 0) ||
      CaMgm.adv_copy_subject_alt_name
    text = Ops.add(
      Ops.add(text, "Subject Alt Name:         "),
      CaMgm.adv_cri_subject_alt_name ? _("(critical) ") : ""
    )
    text = Ops.add(
      text,
      CaMgm.adv_copy_subject_alt_name ?
        _("Copy Standard E-Mail Address") :
        ""
    )
    i = 0
    if CaMgm.adv_cri_subject_alt_name || CaMgm.adv_copy_subject_alt_name
      i = Ops.add(i, 1)
      text = Ops.add(text, "\n")
    end
    Builtins.foreach(CaMgm.adv_subject_alt_name_list) do |element|
      if i == 0
        text = Ops.add(
          Ops.add(Ops.add(text, Ops.get_string(element, "kind", "")), ":"),
          Ops.get_string(element, "name", "")
        )
      else
        text = Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(text, "                          "),
              Ops.get_string(element, "kind", "")
            ),
            ":"
          ),
          Ops.get_string(element, "name", "")
        )
      end
      text = Ops.add(text, "\n")
      i = Ops.add(i, 1)
    end
    text = Ops.add(text, "\n") if i == 0
  end
  if Ops.greater_than(Builtins.size(CaMgm.adv_issuer_alt_name_list), 0) ||
      CaMgm.adv_copy_issuer_alt_name
    text = Ops.add(
      Ops.add(text, "Issuer Alt Name:          "),
      CaMgm.adv_cri_issuer_alt_name ? _("(critical) ") : ""
    )
    text = Ops.add(
      text,
      CaMgm.adv_copy_issuer_alt_name ?
        _("Copy Subject Alt Name from CA") :
        ""
    )
    i = 0
    if CaMgm.adv_cri_issuer_alt_name || CaMgm.adv_copy_issuer_alt_name
      i = Ops.add(i, 1)
      text = Ops.add(text, "\n")
    end
    Builtins.foreach(CaMgm.adv_issuer_alt_name_list) do |element|
      if i == 0
        text = Ops.add(
          Ops.add(Ops.add(text, Ops.get_string(element, "kind", "")), ":"),
          Ops.get_string(element, "name", "")
        )
      else
        text = Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(text, "                          "),
              Ops.get_string(element, "kind", "")
            ),
            ":"
          ),
          Ops.get_string(element, "name", "")
        )
      end
      text = Ops.add(text, "\n")
      i = Ops.add(i, 1)
    end
    text = Ops.add(text, "\n") if i == 0
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsBaseUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsBaseUrl:                "),
        CaMgm.exp_netscape_nsBaseUrl
      ),
      CaMgm.exp_cri_netscape_nsBaseUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsRevocationUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsRevocationUrl:          "),
        CaMgm.exp_netscape_nsRevocationUrl
      ),
      CaMgm.exp_cri_netscape_nsRevocationUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(
      Builtins.size(CaMgm.exp_netscape_nsCaRevocationUrl),
      0
    )
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsCaRevocationUrl:        "),
        CaMgm.exp_netscape_nsCaRevocationUrl
      ),
      CaMgm.exp_cri_netscape_nsCaRevocationUrl ? _(" (critical)\n") : "\n"
    )
  end
  if CaMgm.adv_digitalSignature || CaMgm.adv_nonRepudiation ||
      CaMgm.adv_cRLSign ||
      CaMgm.adv_keyEncipherment ||
      CaMgm.adv_dataEncipherment ||
      CaMgm.adv_encipherOnly ||
      CaMgm.adv_keyAgreement ||
      CaMgm.adv_keyCertSign ||
      CaMgm.adv_decipherOnly
    text = Ops.add(
      Ops.add(text, "Key Usage:                "),
      CaMgm.adv_cri_key_usage ? _("(critical)\n") : ""
    )
    nextLine = CaMgm.adv_cri_key_usage
    if CaMgm.adv_digitalSignature
      if !nextLine
        nextLine = true
        text = Ops.add(text, "digitalSignature\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "digitalSignature\n"
        )
      end
    end
    if CaMgm.adv_nonRepudiation
      if !nextLine
        nextLine = true
        text = Ops.add(text, "nonRepudiation\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "nonRepudiation\n"
        )
      end
    end
    if CaMgm.adv_cRLSign
      if !nextLine
        nextLine = true
        text = Ops.add(text, "cRLSign\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "cRLSign\n"
        )
      end
    end
    if CaMgm.adv_keyEncipherment
      if !nextLine
        nextLine = true
        text = Ops.add(text, "keyEncipherment\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "keyEncipherment\n"
        )
      end
    end
    if CaMgm.adv_dataEncipherment
      if !nextLine
        nextLine = true
        text = Ops.add(text, "dataEncipherment\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "dataEncipherment\n"
        )
      end
    end

    if CaMgm.adv_encipherOnly
      if !nextLine
        nextLine = true
        text = Ops.add(text, "encipherOnly\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "encipherOnly\n"
        )
      end
    end
    if CaMgm.adv_keyAgreement
      if !nextLine
        nextLine = true
        text = Ops.add(text, "keyAgreement\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "keyAgreement\n"
        )
      end
    end
    if CaMgm.adv_keyCertSign
      if !nextLine
        nextLine = true
        text = Ops.add(text, "keyCertSign\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "keyCertSign\n"
        )
      end
    end
    if CaMgm.adv_decipherOnly
      if !nextLine
        nextLine = true
        text = Ops.add(text, "decipherOnly\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "decipherOnly\n"
        )
      end
    end
    if !nextLine
      nextLine = true
      text = Ops.add(text, "\n")
    end
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsRenewalUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsRenewalUrl:             "),
        CaMgm.exp_netscape_nsRenewalUrl
      ),
      CaMgm.exp_cri_netscape_nsRenewalUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsCaPolicyUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsCaPolicyUrl:            "),
        CaMgm.exp_netscape_nsCaPolicyUrl
      ),
      CaMgm.exp_cri_netscape_nsCaPolicyUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.adv_nsSslServerName), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsSslServerName:          "),
        CaMgm.adv_nsSslServerName
      ),
      CaMgm.adv_cri_nsSslServerName ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.adv_distribution_point), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "CRL Distribution Point:   "),
        CaMgm.adv_distribution_point
      ),
      CaMgm.adv_cri_distribution_point ? _(" (critical)\n") : "\n"
    )
  end

  text = Ops.add(text, "</pre>")

  contents = VBox()
  contents = Builtins.add(contents, RichText(text))
  contents = Builtins.add(
    contents,
    Right(PushButton(Id(:edit), Opt(:key_F4), _("&Edit Request")))
  )

  # To translators: dialog label
  Wizard.SetContents(
    Builtins.sformat(_("Sign Request as a %1 (Step 2/2)"), kind),
    contents,
    helptext,
    true,
    true
  )
  Wizard.SetNextButton(:next, _("Sign Request"))

  ui = nil
  begin
    ui = Convert.to_symbol(UI.UserInput)

    if ui == :next
      #signing request
      if !cert_write("signRequest")
        showErrorCaManagement
        ui = :again
      else
        CaMgm.adv_subject_alt_name_show_email = false
        Popup.Message(_("The request has been signed."))
      end
    elsif ui == :edit
      CaMgm.adv_subject_alt_name_show_email = true
    end
  end until Builtins.contains([:back, :next, :abort, :edit], ui)

  ui
end

- (Object) signRequestInit(kind)

Values initializing for creating a Request

Parameters:

  • kind (String)

    (“Client Request”,“Server Request”,“CA Request”)

Returns:

  • next,abort



600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
# File '../../src/include/ca-management/signRequest.rb', line 600

def signRequestInit(kind)
  @currentRequestMap = Convert.to_map(
    YaPI::CaManagement.ReadRequest(
      {
        "caName"   => CaMgm.currentCA,
        "caPasswd" => getPassword(CaMgm.currentCA),
        "request"  => CaMgm.currentRequest,
        "type"     => "extended"
      }
    )
  )
  Builtins.y2milestone(
    "ReadRequest(%1,%2): %3",
    CaMgm.currentCA,
    CaMgm.currentRequest,
    @currentRequestMap
  )
  if @currentRequestMap == nil
    showErrorCaManagement
    return :abort
  end

  CaMgm.slectedRequestExtention = []
  CaMgm.requestExtentionValue = {}
  CaMgm.requestKind = ""
  CaMgm.requestSubject = ""
  CaMgm.validPeriod = 30

  # IS CA ?
  if Ops.get_string(@currentRequestMap, "IS_CA", "") == "1"
    if kind != "CA Request"
      message = Builtins.sformat(
        _("This is a CA request. Really sign it as a %1?"),
        kind
      )
      return :abort if !Popup.YesNo(message)
    end
  else
    if kind == "CA Request"
      message = _(
        "This is not a CA request. Really sign it as a CA request?"
      )
      return :abort if !Popup.YesNo(message)
    end
  end

  if kind == "CA Request"
    new_cert_init("Sub CA")
    CaMgm.requestKind = "ca"
  elsif kind == "Server Request"
    new_cert_init("Server Certificate")
    CaMgm.requestKind = "server"
  elsif kind == "Client Request"
    new_cert_init("Client Certificate")
    CaMgm.requestKind = "client"
  end

  # Subject
  CaMgm.requestSubject = Ops.get_string(@currentRequestMap, "DN", "")

  # Filling up reqeust extentions
  opensslExtentions = Ops.get_map(
    @currentRequestMap,
    "OPENSSL_EXTENSIONS",
    {}
  )
  Builtins.foreach(opensslExtentions) do |key, value|
    if Builtins.contains(CaMgm.validRequestExtention, key)
      CaMgm.requestExtentionValue = Builtins.add(
        CaMgm.requestExtentionValue,
        key,
        value
      )
    else
      Popup.Error(Builtins.sformat(_("Extension \"%1\" not found."), key))
    end
  end

  new_cert_save_default

  :next
end

- (void) unsetRequestExtentions(extention)

This method returns an undefined value.

Reset an accpetation of a RequestExtention

Parameters:

  • request

    extention



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File '../../src/include/ca-management/signRequest.rb', line 174

def unsetRequestExtentions(extention)
  Builtins.y2milestone("Unset requestExtention %1", extention)
  if extention == "subjectKeyIdentifier"
    CaMgm.exp_cri_subjectKeyIdentifier = @sav_exp_cri_subjectKeyIdentifier
    CaMgm.exp_subjectKeyIdentifier = @sav_exp_subjectKeyIdentifier
  elsif extention == "subjectAltName"
    CaMgm.adv_cri_subject_alt_name = @sav_adv_cri_subject_alt_name
    CaMgm.adv_copy_subject_alt_name = @sav_adv_copy_subject_alt_name
  elsif extention == "basicConstraints"
    CaMgm.adv_pathlen = @sav_adv_pathlen
    CaMgm.adv_pathlenValue = @sav_adv_pathlenValue
    CaMgm.adv_cri_ca = @sav_adv_cri_ca
    CaMgm.adv_ca = @sav_adv_ca
  elsif extention == "keyUsage"
    CaMgm.adv_cri_key_usage = @sav_adv_cri_key_usage
    CaMgm.adv_digitalSignature = @sav_adv_digitalSignature
    CaMgm.adv_nonRepudiation = @sav_adv_nonRepudiation
    CaMgm.adv_cRLSign = @sav_adv_cRLSign
    CaMgm.adv_keyEncipherment = @sav_adv_keyEncipherment
    CaMgm.adv_dataEncipherment = @sav_adv_dataEncipherment
    CaMgm.adv_encipherOnly = @sav_adv_encipherOnly
    CaMgm.adv_keyAgreement = @sav_adv_keyAgreement
    CaMgm.adv_keyCertSign = @sav_adv_keyCertSign
    CaMgm.adv_decipherOnly = @sav_adv_decipherOnly
  elsif extention == "extendedKeyUsage"
    CaMgm.exp_cri_extendedKeyUsage = @sav_exp_cri_extendedKeyUsage
    CaMgm.exp_extendedKeyUsage = @sav_exp_extendedKeyUsage
  elsif extention == "nsComment"
    CaMgm.adv_cri_nsComment = @sav_adv_cri_nsComment
    CaMgm.adv_nsComment = @sav_adv_nsComment
  elsif extention == "authorityKeyIdentifier"
    CaMgm.exp_cri_authorityKeyIdentifier = @sav_exp_cri_authorityKeyIdentifier
    CaMgm.exp_authorityKeyIdentifier = @sav_exp_authorityKeyIdentifier
  elsif extention == "nsCertType"
    CaMgm.adv_cri_nsCertType = @sav_adv_cri_nsCertType
    CaMgm.adv_client = @sav_adv_client
    CaMgm.adv_server = @sav_adv_server
    CaMgm.adv_sslCA = @sav_adv_sslCA
    CaMgm.adv_email = @sav_adv_email
    CaMgm.adv_reserved = @sav_adv_reserved
    CaMgm.adv_emailCA = @sav_adv_emailCA
    CaMgm.adv_objsign = @sav_adv_objsign
    CaMgm.adv_objCA = @sav_adv_objCA
  elsif extention == "nsCaRevocationUrl"
    CaMgm.exp_cri_netscape_nsCaRevocationUrl = @sav_exp_cri_netscape_nsCaRevocationUrl
    CaMgm.exp_netscape_nsCaRevocationUrl = @sav_exp_netscape_nsCaRevocationUrl
  elsif extention == "nsCaPolicyUrl"
    CaMgm.exp_cri_netscape_nsCaPolicyUrl = @sav_exp_cri_netscape_nsCaPolicyUrl
    CaMgm.exp_netscape_nsCaPolicyUrl = @sav_exp_netscape_nsCaPolicyUrl
  elsif extention == "nsBaseUrl"
    CaMgm.exp_cri_netscape_nsBaseUrl = @sav_exp_cri_netscape_nsBaseUrl
    CaMgm.exp_netscape_nsBaseUrl = @sav_exp_netscape_nsBaseUrl
  elsif extention == "nsRenewalUrl"
    CaMgm.exp_cri_netscape_nsRenewalUrl = @sav_exp_cri_netscape_nsRenewalUrl
    CaMgm.exp_netscape_nsRenewalUrl = @sav_exp_netscape_nsRenewalUrl
  elsif extention == "nsRevocationUrl"
    CaMgm.exp_cri_netscape_nsRevocationUrl = @sav_exp_cri_netscape_nsRevocationUrl
    CaMgm.exp_netscape_nsRevocationUrl = @sav_exp_netscape_nsRevocationUrl
  elsif extention == "nsSslServerName"
    CaMgm.adv_cri_nsSslServerName = @sav_adv_cri_nsSslServerName
    CaMgm.adv_nsSslServerName = @sav_adv_nsSslServerName
  elsif extention == "issuserAltName"
    CaMgm.adv_cri_issuer_alt_name = @sav_adv_cri_issuer_alt_name
    CaMgm.adv_copy_subject_alt_name = @sav_adv_copy_subject_alt_name
  elsif extention == "crlDistributionPoints"
    CaMgm.adv_cri_distribution_point = @sav_adv_cri_distribution_point
    CaMgm.adv_distribution_point = @sav_adv_distribution_point
  elsif extention == "certificatePolicies"
    Builtins.y2milestone("certificatePolicies ignored")
  else
    Popup.Error(
      Builtins.sformat(_("Extension \"%1\" not found."), extention)
    )
  end

  nil
end