aboutsummaryrefslogtreecommitdiff
path: root/scripts/resource-cert-samples/LIR2.req
blob: 96d673beb7ad9cc0c534319105be429c1108e9ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-----BEGIN CERTIFICATE REQUEST-----
MIIDszCCApsCAQAwGzEZMBcGA1UEAxMQVEVTVCBFTlRJVFkgTElSMjCCASIwDQYJ
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAPEYtnkLNcWDZEiDMQOe53IoZbGsYeF3
LsBN8LEcYdjMWi3HC5t4ej79N636sHMLnPy7b2DqOO+u0Se4gVkPs+fQZ7Ki9U/i
BMbME58zKDWWetvOrJ3TZD24RLzLQyKS1jwuv5duOWpuaJNdHKhYt6N6JkT+/jCt
4gWJTMnvLOBOMWk/3ZEc8LAlTD6EiupeA7OozZAaHsjgr/4R7SEGvTxeCKGT4kFD
QzjTIbNM+oWLQ1dgXbugeOUzR6gzdr7fbmNh4zGLXY4Mx/XIkQy+V8fyvL4Lunof
9hnx6wB0wRLC3CsujfAK/3/oYAiQulH80JARN/OeRLZkQ2ldYdPhjXcCAwEAAaCC
AVEwggFNBgkqhkiG9w0BCQ4xggE+MIIBOjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud
DgQWBBQDet8M39yTPfelzCd73CL26VWX8DAOBgNVHQ8BAf8EBAMCAQYwQQYIKwYB
BQUHAQsENTAzMDEGCCsGAQUFBzAFhiVyc3luYzovL3dvbWJhdHMtci11cy5oYWN0
cm4ubmV0L0xJUjIvMEMGCCsGAQUFBwEBBDcwNTAzBggrBgEFBQcwAoYncnN5bmM6
Ly93b21iYXRzLXItdXMuaGFjdHJuLm5ldC9SSVIuY2VyMBoGCCsGAQUFBwEIAQH/
BAswCaAHMAUCAwD8IDBUBggrBgEFBQcBBwEB/wRFMEMwQQQCAAIwOzAmAxECIAEN
uAAAAAAAAAAAAAAARAMRACABDbgAAAAAAAAAAAAAAQADEQAgAQ24AAAAAAAAABAA
AABEMA0GCSqGSIb3DQEBBQUAA4IBAQCFx6Mb43W5xnHDV/cqywQ3qJjVQUsl6Gcg
1h426JuSWoB526DFqFxBAmZR5DK+L8jU7jxBJn7tG6P22GrITSbU4BDVdFCD9znO
juds7+q/qvfTDSNrNwyzldW/UaL3VJ0YF2xXutLJC4jbkH4QfEcmGriGFTRiwvJS
LJvotN7i2TNKtj3ARaIaKhonzPZg7Qn/bck2KJutG00gm9u3m9wGZ37+tDQE1yMd
sqX/uhtZB/YM7q3OGeaj8hkjCMkInZL/1FCzxp4qo3F25KLiWNVz+0xxW4A/1kA8
a1Rdzb9+y318vQce1eAgMo/64tABUYEILwkAXJ6sPBV2V7PdksW4
-----END CERTIFICATE REQUEST-----
different problems' href='/sra/rpki.net/commit/rpkid/rpki-confgen.py?id=53cbf373478183dcd6dbfff0cd46b4b3328b1b6d'>53cbf373
81bf6076
53cbf373
978db61b
40fd44a0
978db61b
40fd44a0
81bf6076
53cbf373

ae3857ec

40fd44a0



53cbf373

























df1985b9
53cbf373



3ec3b1ee
53cbf373
978db61b
53cbf373



bc50feb5





53cbf373


6bef5815
978db61b












758898ff
81bf6076
978db61b
758898ff
6bef5815
978db61b





758898ff
6bef5815






























































df1985b9
6bef5815
53cbf373

6bef5815
df1985b9
6bef5815
53cbf373
6bef5815

53cbf373
6bef5815
df1985b9
53cbf373


6bef5815
df1985b9
6bef5815

df1985b9
6bef5815
89506621
6bef5815
89506621


6bef5815
89506621
6bef5815

89506621
6bef5815
df1985b9

6bef5815
df1985b9







53cbf373
53cbf373
6bef5815










40fd44a0

6bef5815

758898ff
6bef5815
758898ff
40fd44a0

53cbf373
6bef5815





53cbf373

758898ff
6bef5815





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
122
123
124
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
170
171
172
173
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
251
252
253
254
255
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

                     

      


                                                                  

                                                                        








                                                                      


                               
          
               
             



                                                       


                
                 
 
                                     
                                                                                    

                                                                                        












                                       


                                           
                      
                                                                             


                       
                                                        
                      
                                              
                          
                                                                
         
                                                                       

                              

                                                                         



                                                               

























                                                                              
                                                                             



                                              
                                                                
                      
                                              



                              





                                                                           


                          
                               












                                                          
                     
                                      
                              
 
                          





                                                                                 
 






























































                                                                                     
                                                       
                                              

                                          
                                   
                                                    
                                      
 

                        
        
                                     
                                        


                                                               
                                   
                                                    

                                       
 
                          
        
                                       


                                                                 
                                   
                                                    

                                                                          
 
                                 

                          
                                                         







                                                            
 
 










                                                                         

                            

                                                   
                    
                                                
               

                            
 





                                                 

                                 
 





                          
#!/usr/bin/env python

# $Id$
#
# Copyright (C) 2014  Dragon Research Labs ("DRL")
# Portions copyright (C) 2013  Internet Systems Consortium ("ISC")
# 
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
# 
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL DRL OR
# ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

import os
import sys
import argparse
import base64
import textwrap

from lxml.etree import Element, SubElement, ElementTree

space4 = " " * 4
space6 = " " * 6
space8 = " " * 8
star78 = "*" * 78

wiki_wrapper = textwrap.TextWrapper()
conf_wrapper = textwrap.TextWrapper(initial_indent = "# ", subsequent_indent = "# ")
xml6_wrapper = textwrap.TextWrapper(initial_indent = space6, subsequent_indent = space6)
xml8_wrapper = textwrap.TextWrapper(initial_indent = space8, subsequent_indent = space8)

class Option(object):

  def __init__(self, name, value, doc):
    self.name = name
    self.value = value
    self.doc = doc

  @property
  def width(self):
    return len(self.name)

  def to_xml(self):
    x = Element("option", name = self.name)
    if self.value is not None:
      x.set("value", self.value)
    for d in self.doc:
      SubElement(x, "doc").text = "\n" + xml8_wrapper.fill(d) + "\n" + space6
    return x

  def to_wiki(self, f):
    f.write("\n== %s == #%s\n" % (self.name, self.name))
    for d in self.doc:
      f.write("\n%s\n" % wiki_wrapper.fill(d))
    if self.value is None:
      f.write("\n%s\n" % wiki_wrapper.fill("No default value."))
    else:
      f.write("\n{{{\n#!ini\n%s = %s\n}}}\n" % (self.name, self.value))

  def to_conf(self, f, width):
    for i, d in enumerate(self.doc):
      f.write("%s\n%s\n" % ("" if i == 0 else "#", conf_wrapper.fill(d)))
    if self.value is None:
      f.write("\n#%-*s = ???\n" % (width - 1, self.name))
    else:
      f.write("\n%-*s = %s\n" % (width, self.name, self.value))

class Section(object):

  def __init__(self, name):
    self.name = name
    self.doc = []
    self.options = []

  @property
  def width(self):
    return max(o.width for o in self.options)

  @classmethod
  def from_xml(cls, elt):
    self = cls(name = elt.get("name"))
    for x in elt.iterchildren("doc"):
      self.doc.append(" ".join(x.text.split()))
    for x in elt.iterchildren("option"):
      self.options.append(Option(name = x.get("name"), value = x.get("value"),
                                 doc = [" ".join(d.text.split())
                                        for d in x.iterchildren("doc")]))
    return self

  def to_xml(self):
    x = Element("section", name = self.name)
    for d in self.doc:
      SubElement(x, "doc").text = "\n" + xml6_wrapper.fill(d) + "\n" + space4
    x.extend(o.to_xml() for o in self.options)
    return x

  def to_wiki(self, f):
    f.write("\n= [%s] section = #%s\n" % (self.name, self.name))
    for d in self.doc:
      f.write("\n%s\n" % wiki_wrapper.fill(d))
    for o in self.options:
      o.to_wiki(f)

  def to_conf(self, f, width):
    f.write("\n" + "#" * 78 + "\n\n[" + self.name + "]\n")
    if self.doc:
      f.write("\n##")
      for i, d in enumerate(self.doc):
        f.write("%s\n%s\n" % ("" if i == 0 else "#", conf_wrapper.fill(d)))
      f.write("##\n")
    for o in self.options:
      o.to_conf(f, width)

def wiki_header(f, ident, toc):
  f.write("\n".join((
    "{{{",
    "#!comment",
    "",
    star78,
    "THIS PAGE WAS GENERATED AUTOMATICALLY, DO NOT EDIT.",
    "",
    "Generated from " + ident,
    "            by $Id$",
    star78,
    "",
    "}}}",
    "")))
  if toc is not None:
    f.write("[[TracNav(%s)]]\n" % toc)
  f.write("[[PageOutline]]\n")

def conf_header(f, ident):
  f.write("\n".join((
    "# Automatically generated.  Edit as needed, but be careful of overwriting.",
    "#",
    "# Generated from " + ident,
    "#             by $Id$",
    "")))


# http://stackoverflow.com/questions/9027028/argparse-argument-order

class CustomAction(argparse.Action):
  def __call__(self, parser, namespace, values, option_string = None):
    if not "ordered_args" in namespace:
      namespace.ordered_args = []
    namespace.ordered_args.append((self.dest, values))

class CustomFlagAction(argparse.Action):
  def __init__(self, option_strings, dest, default = None,
               required = False, help = None):
    super(CustomFlagAction, self).__init__(
      option_strings = option_strings, dest = dest, nargs = 0,
      const = None, default = default, required = required, help = help)
  def __call__(self, parser, namespace, values, option_string = None):
    if not "ordered_args" in namespace:
      namespace.ordered_args = []
    namespace.ordered_args.append((self.dest, None))


class main(object):

  def __init__(self):
    self.sections = []
    self.section_map = None
    self.option_map = None
    self.ident = None
    self.toc = None

    parser = argparse.ArgumentParser(description = __doc__)
    parser.add_argument("--read-xml",   metavar = "FILE",  action = CustomAction,
                        required = True, type = argparse.FileType("r"),
                        help = "XML input file defining sections and options")
    parser.add_argument("--write-xml",  metavar = "FILE",  action = CustomAction,
                        help = "XML file to write")
    parser.add_argument("--write-wiki", metavar = "FILE", action = CustomAction,
                        help = "TracWiki file to write")
    parser.add_argument("--write-conf", metavar = "FILE", action = CustomAction,
                        help = "rpki.conf configuration file to write")
    parser.add_argument("--set",        metavar = "VARVAL",    action = CustomAction,
                        help = "variable setting in form \"VAR=VAL\"")
    parser.add_argument("--pwgen",      metavar = "VAR",       action = CustomAction,
                        help = "set variable to generated password")
    parser.add_argument("--toc",        metavar = "TRACNAV",   action = CustomAction,
                        help = "set TOC value to use with TracNav plugin")
    parser.add_argument("--autoconf",   action = CustomFlagAction,
                        help = "configure [autoconf] section")
    args = parser.parse_args()

    for cmd, arg in args.ordered_args:
      getattr(self, "do_" + cmd)(arg)


  def do_read_xml(self, arg):
    self.option_map = None
    root = ElementTree(file = arg).getroot()
    self.ident = root.get("ident")
    self.sections.extend(Section.from_xml(x) for x in root)
    self.option_map = {}
    self.section_map = {}
    for section in self.sections:
      if section.name in self.section_map:
        sys.exit("Duplicate section %s" % section.name)
      self.section_map[section.name] = section
      for option in section.options:
        name = (section.name, option.name)
        if name in self.option_map:
          sys.exit("Duplicate option %s::%s" % name)
        self.option_map[name] = option


  def do_set(self, arg):
    try:
      name, value = arg.split("=", 1)
      section, option = name.split("::")
    except ValueError:
      sys.exit("Couldn't parse --set specification \"%s\"" % a)
    name = (section, option)
    if name not in self.option_map:
      sys.exit("Couldn't find option %s::%s" % name)
    self.option_map[name].value = value


  def do_pwgen(self, arg):
    try:
      section, option = arg.split("::")
    except ValueError:
      sys.exit("Couldn't parse --pwgen specification \"%s\"" % a)
    name = (section, option)
    if name not in self.option_map:
      sys.exit("Couldn't find option %s::%s" % name)
    self.option_map[name].value = base64.urlsafe_b64encode(os.urandom(66))


  def do_autoconf(self, ignored):
    try:
      import rpki.autoconf
      for option in self.section_map["autoconf"].options:
        try:
          option.value = getattr(rpki.autoconf, option.name)
        except AttributeError:
          pass
    except ImportError:
      sys.exit("rpki.autoconf module is not available")
    except KeyError:
      sys.exit("Couldn't find autoconf section")


  def do_write_xml(self, arg):
    x = Element("configuration", ident = self.ident)
    x.extend(s.to_xml() for s in self.sections)
    ElementTree(x).write(arg, pretty_print = True, encoding = "us-ascii")


  def do_write_wiki(self, arg):
    if "%" in arg:
      for section in self.sections:
        with open(arg % section.name, "w") as f:
          wiki_header(f, self.ident, self.toc)
          section.to_wiki(f)
    else:
      with open(arg, "w") as f:
        for i, section in enumerate(self.sections):
          if i == 0:
            wiki_header(f, self.ident, self.toc)
          else:
            f.write("\f\n")
          section.to_wiki(f)


  def do_write_conf(self, arg):
    with open(arg, "w") as f:
      conf_header(f, self.ident)
      width = max(s.width for s in self.sections)
      for section in self.sections:
        section.to_conf(f, width)


  def do_toc(self, arg):
    self.toc = arg


if __name__ == "__main__":
  main()